Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Unsolved QListView and QListWidget

    General and Desktop
    3
    4
    7109
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MokJ last edited by MokJ

      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?
      Thank you.

      jsulm JonB 2 Replies Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @MokJ last edited by

        @MokJ Take a look at http://doc.qt.io/qt-5/model-view-programming.html

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 1
        • JonB
          JonB @MokJ last edited by

          @MokJ
          QListWidget is 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 QListView and the "pre-designed" QListWidget implementation.

          From 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.

          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.

          1 Reply Last reply Reply Quote 2
          • M
            MokJ last edited by MokJ

            Thanks @JonB and @jsulm .
            Can you explain with any sort of example verbally, No code just any clue, cause I have tried both QListView and QlistWidget so a bit more clarity would be appreciated.

            1 Reply Last reply Reply Quote 1
            • First post
              Last post