Solved Text from database to QStandardItemModel
-
@mrjj
It gives the same error message for the; model->setQuery (q); ```line....
-
@gabor53
hmm.
Do you have
QT += sql
in the .pro file? -
-
@gabor53
and
#include <QSqlQueryModel>
? -
I have that one too.
-
@gabor53
ok. no idea then.
http://doc.qt.io/qt-5/qsqlquerymodel.htmlWhat version of Qt do you have ? did you compile yourself?
-
I have 5.6 and Yes I compiled myself.
-
Hi,
That's because you are using a QSqlTableModel, you should use a QSqlQueryModel.
QSqlTableModel goal is to make a table accessible.
-
QSqlTableModel
Good catch :)
-
@mrjj
The following worked:model = new QSqlTableModel(this); model->setTable ("Items"); model->select (); ui->tableView->setModel (model);
Thank you for all your help!