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

Difference between List View and List Widget?



  • What is the difference between a List View and a List Widget?

    If I'm converting a Visual Studio List Box in a dialog, which one should I use (View or Widget)?


  • Qt Champions 2019

    Isn't the documentation clear enough? http://doc.qt.io/qt-5/qlistwidget.html#details

    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.


  • Lifetime Qt Champion

    @Sprezzatura

    • If I'm converting a Visual Studio List Box in a dialog, which one should I use (View or Widget)?

    Well the ListWidget resembles more how a traditional listbox works.
    That said, using a model ( ListView) allows for automatic updates to the model
    if the Data in the listbox changes. This can be very handy if the data represented in the
    "listbox" is shared/replicated among other widgets.
    If you already have such synchronization in place, or the data is not shared,
    ListWidget might be the fastest route for conversion.
    So I would say it mostly depends on the way the listbox data is used/shared/what it represents.



  • Thank you @mrjj for a useful answer, that's the kind of high-level overview answer I was looking for. I'm using a plain, ordinary list box where the items are displayed but not edited by the user.


  • Lifetime Qt Champion

    @Sprezzatura
    hi
    well if the LB items are not shared with other structures / updated often, i would
    go with ListWidget as more changes to the code seems required to take full advantage of having a model.


Log in to reply