Is there a way to add my QSqlQueryModel to a QListWidget? If not is there a way to add the database row id to a QListWidgetItem?
I cant figure this out from the documentation on QListWidget. I can add items to the list but can only think to use the row number of the item as the hidden index which wont work if index numbers are out of order.
OK, here is the deal:
The
QListWidgetis part of the older Qt3 data widget set.The widget you actually want is part of the newer “interview” Qt MVC framework. It is called
QListView.It can be a bit confusing.
In general: A “QxxxxView” widget can be bound to a “QxxxxModel” object, such as the
QSqlQueryModelyou asked about.See:
http://qt-project.org/doc/qt-4.8/qlistview.html
And:
http://qt-project.org/doc/qt-4.8/model-view-programming.html
Lot’s of good examples. For instance:
http://qt-project.org/doc/qt-4.8/sql-querymodel.html
Good luck.
🙂