Cannot access private member?
-
I have this trigger function for a Window i created:
void MainWindow::on_searchProdutos_textChanged()
{
QSqlQuery* qry = new QSqlQuery(DATABASE_NAME);
QSqlQueryModel* modal = new QSqlQueryModel;qry->prepare("select * from clientes"); qry->exec(); modal->setQuery(*qry); ui->listProdutos->setModel(modal); return;}
And the compiler gives me the following error...
64: error: C2248: 'QListWidget::setModel': cannot access private member declared in class 'QListWidget'I've already coded several functions like these already, why is it erroring out here?
Thanks in advance for any help! =)
-
I have this trigger function for a Window i created:
void MainWindow::on_searchProdutos_textChanged()
{
QSqlQuery* qry = new QSqlQuery(DATABASE_NAME);
QSqlQueryModel* modal = new QSqlQueryModel;qry->prepare("select * from clientes"); qry->exec(); modal->setQuery(*qry); ui->listProdutos->setModel(modal); return;}
And the compiler gives me the following error...
64: error: C2248: 'QListWidget::setModel': cannot access private member declared in class 'QListWidget'I've already coded several functions like these already, why is it erroring out here?
Thanks in advance for any help! =)
It looks like your listProdutos is a
QListWidgetinstead of aQListView. If you want to work with the model/view concept you want to use just the plainQListView. TheQListWidgetis a convenience widget that merges aQListViewand a corresponding model into one widget. The model in that widget is a private attribute and thus you get the error that you are not allowed to access that member.