I tried removing some records from QSqlQuery using query.record().remove(pos) but it doesn't work at all. Is there any way to remove the record from QSqlQuery? I know about QSqlQueryModel, but I would like to use QSqlQuery, because it works fine for my application.
There is the code:
#include "QtSql/QtSql"
#include "QtSql/QSqlRecord"
sql_str = "select * from param";
query.prepare(sql_str);
query.exec();
int index=0;
query.seek(-1);
while(query.next()){
query.record().clear();
query.record().clearValues();
query.record().remove(0);
ui
->tableWidget_2
->setItem
(index,
0,
new QTableWidgetItem(query.
record().
value(0).
toString()));
ui
->tableWidget_2
->setItem
(index,
1,
new QTableWidgetItem(query.
value(1).
toString()));
ui
->tableWidget_2
->setItem
(index,
2,
new QTableWidgetItem(query.
value(2).
toString()));
ui
->tableWidget_2
->setItem
(index,
3,
new QTableWidgetItem(query.
value(3).
toString()));
index++;
}
#include "QtSql/QtSql"
#include "QtSql/QSqlRecord"
QString sql_str;
sql_str = "select * from param";
QSqlQuery query;
query.prepare(sql_str);
query.exec();
int index=0;
query.seek(-1);
while(query.next()){
query.record().clear();
query.record().clearValues();
query.record().remove(0);
ui->tableWidget_2->setItem(index,0,new QTableWidgetItem(query.record().value(0).toString()));
ui->tableWidget_2->setItem(index,1,new QTableWidgetItem(query.value(1).toString()));
ui->tableWidget_2->setItem(index,2,new QTableWidgetItem(query.value(2).toString()));
ui->tableWidget_2->setItem(index,3,new QTableWidgetItem(query.value(3).toString()));
index++;
}
To copy to clipboard, switch view to plain text mode
I use Qt Creator 1.3.0 based on Qt 4.6.0 (32-bit)
Nov 27 2009 at 14:53:38
Revision c0e849ecc3
Bookmarks