Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QStringListModel items not showing in QListView
I have a QStringListModel as the model for a QListView, but the strings aren't showing in the list view. If I switch it to a QTableView or QComboBox it shows the strings, but I can't get it to work with a list view.
I have the model here. The QListView's model is set in the MainWindow's constructor.
I've been stuck on this for a few days now, and I can't seem to find anything that would point me in the right direction, so any help is appreciated.
JonB last edited by JonB
Is http://www.bogotobogo.com/Qt/Qt5_QListView_QStringListModel_ModelView_MVC.php helpful?
Or briefer (it's Qt4) https://stackoverflow.com/questions/5802313/qt4-qstringlistmodel-in-qlistview ?
Hi and welcome to devnet,
In addition to @JNBarchan, why are you using QStringListModel since you manage everything by hand anyway ?
@JNBarchan Thanks, I'll take a look at these.
I'm not sure what you mean? Should I use an item-based ListView instead?
I'm still new to Qt and this is a portfolio project so I'm trying to do this 'by the book', using best practices.
So I put a call to setStringList() in the constructor of EntryModel and removed the overwritten rowCount() and data() functions, and it's working. I was using a class that was inheriting from QAbstractListModel as reference for EntryModel, which is why I originally overwrote rowCount() and data(), though, I didn't need to.