Hello. Now I have a problem when using QSqlQueryModel or QSqlTableModel. I installed an open-source version of Qt 4.6.2 for VS2008 and Qt 1.4.4 add-in for VS2008 on WinXP. The VC++ compiler always throw the error message "error C2248: 'QSqlTableModel::setQuery' : cannot access protected member declared in class 'QSqlTableModel'" when I set a parameter in setQuery() function as below:
// assume that 'stock' is a table.
model->setQuery(tr("SELECT * FROM stock WHERE id = %1").arg(ui.searchComboBox->currentText()));
QSqlTableModel *model;
// assume that 'stock' is a table.
model->setQuery(tr("SELECT * FROM stock WHERE id = %1").arg(ui.searchComboBox->currentText()));
To copy to clipboard, switch view to plain text mode
or
// assume that 'stock' is a table.
model->setQuery("SELECT * FROM stock WHERE id = 1");
QSqlTableModel *model;
// assume that 'stock' is a table.
model->setQuery("SELECT * FROM stock WHERE id = 1");
To copy to clipboard, switch view to plain text mode
But according to a Qt documentation, it said that user can pass a string into setQuery() function. So is it a bug and what should I do?
Thanks a lot!
Bookmarks