// vLastId is a ID int
// n becomes 2
// query is valid
int n=viewport->db->Count("customer_addresses a,contacts c",
"c.id_customer=a.id_customer AND c.id="+QString::number(vLastId
));
QSqlQuery query
=viewport
->db
->Select
("a.id,a.ragsoc",
"customer_addresses a,contacts c",
"c.id_customer=a.id_customer AND c.id="+QString::number(vLastId
));
// two columns defined elsewhere
ui.tbwcaddresses->setSortingEnabled(false);
ui.tbwcaddresses->setRowCount(n);
int row=0;
while(query.next())
{
CTableWidgetItem *zid=new CTableWidgetItem(query.value(0).toString());
ui.tbwcaddresses->setItem(row,0,zid); // this row fails and throws exception
CTableWidgetItem *iragsoc=new CTableWidgetItem(query.value(1).toString());
ui.tbwcaddresses->setItem(row,1,iragsoc); // this doesn't fail, and seems the same operation!
...
row++;
}
ui.tbwcaddresses->setSortingEnabled(true);
// vLastId is a ID int
// n becomes 2
// query is valid
int n=viewport->db->Count("customer_addresses a,contacts c",
"c.id_customer=a.id_customer AND c.id="+QString::number(vLastId));
QSqlQuery query=viewport->db->Select("a.id,a.ragsoc","customer_addresses a,contacts c",
"c.id_customer=a.id_customer AND c.id="+QString::number(vLastId));
// two columns defined elsewhere
ui.tbwcaddresses->setSortingEnabled(false);
ui.tbwcaddresses->setRowCount(n);
int row=0;
while(query.next())
{
CTableWidgetItem *zid=new CTableWidgetItem(query.value(0).toString());
ui.tbwcaddresses->setItem(row,0,zid); // this row fails and throws exception
CTableWidgetItem *iragsoc=new CTableWidgetItem(query.value(1).toString());
ui.tbwcaddresses->setItem(row,1,iragsoc); // this doesn't fail, and seems the same operation!
...
row++;
}
ui.tbwcaddresses->setSortingEnabled(true);
To copy to clipboard, switch view to plain text mode
If I bypass the excepting row, the second setitem works well.
Bookmarks