C++ (Qt)void MainWindow::on_pushButton_2_clicked(){ QFile file("C:/Qt/tableW-build-desktop/table.txt"); if(!file.open(QIODevice::ReadOnly)) return; QTextStream stream(&file); while(!stream.atEnd()) { QString str; stream >> str; QTableWidgetItem *newItem = new QTableWidgetItem; newItem->setText(str); ui->tableWidget->setItem(0, 1, newItem); stream >> str; newItem = new QTableWidgetItem; newItem->setText(str); ui->tableWidget->setItem(0, 2, newItem); } }