[Qt-interest] mqsql query terminating at 100th result

Robert Wood robert.wood at apostrophe.co.uk
Tue Feb 2 17:21:49 CET 2010


It seems to be something purely to do with my primary key.

I've tried this QSqlQueryModel after hours of digging:

QSqlQueryModel model;
	model.setQuery("SELECT * FROM " + ui->tablesComboBox->currentText());


rows = model.rowCount();
ui->tableWidget->setRowCount(rows);
int idNumber;
for (j=0;j<rows;j++)
	{
	idNumber = model.data(model.index(j, 0)).toInt();
	queryString = QString::number(idNumber, 10);
	QTableWidgetItem *qTItem = new QTableWidgetItem;
	qTItem->setText(queryString);
	ui->tableWidget->setItem(j,0,qTItem);
	}

The problem is that, again, I get back the correct number of rows, I 
make my Qt table as long as the sql table, but once I get to the 100th 
member of the sql table, the idNumber returned is 0! Also, on one of my 
large tables there is something weird going on where the 29th member has 
  a primary key of 667 and this returns 0. So it definitely seems to be 
the return value of the primary key only being accepted when it's less 
than 100 which seems crazy.

As the primary keys are so important in linking to other tables, I find 
it hard to believe this is a bug, but after almost three days on this, I 
just can't see what on earth is going on.

Has no-one else come across this? Am I going about it on the wrong way 
still? Is it possible that this really is a bug?

Really would appreciate some help on this!

Cheers,

Rob

Robert Wood wrote:
> It would appear that it's something to do with the * in the SELECT FROM.
> 
> If I change the sql string to:
> 
> queryString = "SELECT ref_des FROM " + ui->tablesComboBox->currentText();
> 
> ...and choose my partslist_table, I get all 1066 results from the sql 
> table populated in my Qt table.
> 
> Wonder whether it's a bug.
> 



More information about the Qt-interest-old mailing list