Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QListView and QListWidget
Qt 6.11 is out! See what's new in the release blog

QListView and QListWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 9.4k Views
  • 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 Offline
    M Offline
    MokJ
    wrote on last edited by MokJ
    #1

    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.

    jsulmJ JonBJ 2 Replies Last reply
    0
    • M 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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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
      1
      • M 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.

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by
        #3

        @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
        2
        • M Offline
          M Offline
          MokJ
          wrote on last edited by MokJ
          #4

          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
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved