Unsolved QListView and QListWidget
I've been reading about those two classes ,But can't figure out exactly when to use them.
for example , I wanted to create a list of labels to be displayed and when I click on the label something should happen.
Instead of doing that I created a QListWidget with String , which works fine.
But the question here is when should QListView be used and why?
jsulm Lifetime Qt Champion last edited by
@MokJ Take a look at http://doc.qt.io/qt-5/model-view-programming.html
JonB last edited by
QListWidgetis derived from
QListView. When you read the http://doc.qt.io/qt-5/qlistwidget.html page, everything there which is added/overridden represents what the differences are between the base
QListViewand the "pre-designed"
QListWidget is a convenience class that provides a list view similar to the one supplied by QListView, but with a classic item-based interface for adding and removing items. QListWidget uses an internal model to manage each QListWidgetItem in the list.
For a more flexible list view widget, use the QListView class with a standard model.
That about sums up the differences. Adding/removing items interface. Plus it has its own model defined, instead of you using standard model or writing your own. That may or may not suit your particular data model.