Cannot access private member?
-
wrote on 30 May 2016, 18:24 last edited by Rust
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! =)
wrote on 30 May 2016, 18:29 last edited by Joel BodenmannIt looks like your listProdutos is a
QListWidget
instead of aQListView
. If you want to work with the model/view concept you want to use just the plainQListView
. TheQListWidget
is a convenience widget that merges aQListView
and 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. -
wrote on 30 May 2016, 18:33 last edited by Rust
It now doesn't cause any error anymore. I checked the attributes at Qt's qt 5.6 page, but was checking indeed for QListView, instead of QListWidget so wasn't figuring out what the issue was.
Thank you for that! =)
1/3