void MainWindow::on_refreshClient_clicked(){ int n = ui->clientTable->rowCount(); for ( int i = 0; i < n; i++ ) ui->clientTable->removeRow(0); QSqlQuery query(db); query.exec("SELECT * FROM guests"); while (query.next()) { ui->clientTable->insertRow(0); ui->clientTable->setItem(0, 0, new QTableWidgetItem(query.value(1).toString())); ui->clientTable->setItem(0, 2, new QTableWidgetItem(query.value(2).toString())); ui->clientTable->setRowHeight(0, 20); } n = ui->clientTable->rowCount(); for ( int i = 0; i < n; i++ ) { query.prepare("SELECT * FROM orders WHERE idguest = ':name'"); query.bindValue(":name",ui->clientTable->item(i,0)->text()); query.exec(); ui->clientTable->setItem(i, 1, new QTableWidgetItem(query.value(0).toInt())); ui->clientTable->setItem(i, 3, new QTableWidgetItem(query.value(4).toString())); ui->clientTable->setItem(i, 4, new QTableWidgetItem(query.value(5).toString())); }}
QSqlQuery::value: not positioned on a valid recordQSqlQuery::value: not positioned on a valid recordQSqlQuery::value: not positioned on a valid record