Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved]Add index value to database in QListWidgetItem



  • Is there a way to add my QSqlQueryModel to a QListWidget? Or is there a way to add the database row id to a QListWidgetItem? I cant figure this out from the "documentation":http://qt-project.org/doc/qt-4.8/qlistwidgetitem.html.



  • Hmm, think your missing the point of the Model/View or widget/View use. For your database you should use the Model/View system, so it would be a QListView instead off a QListWidget. When the database has multiple colums maybe using the QTableView is more appropriate. In the model you control the way the view presents its data. Hope this helps, otherwise supply some code for us to debug/check.



  • Yes. I had received similar advice from stackoverflow also. Although now I realize that class isn't enough either and I need to make my own widget based on some of these model/view classes.


Log in to reply