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 with Groups
QtWS25 Last Chance

QListView with Groups

Scheduled Pinned Locked Moved Unsolved General and Desktop
qlistviewqitemdelegatemodelview
3 Posts 2 Posters 3.1k 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.
  • W Offline
    W Offline
    walkingTarget
    wrote on 22 Dec 2015, 21:15 last edited by
    #1

    I'd like to create a ListView with groups, ala .NET's ListView class. The end goal is something similar to Ubuntu's System Settings dialog, with a root item represented by header text, and the subset of items displayed by clickable icons.

    I'm a bit confused by my options. QListView may not be appropriate, as it is designed to handle non-hierarchical lists. QTreeView, however, isn't quite right either, because I want the subitems to be displayed in an icon view.

    Will this require just a custom QItemDelegate, or will I need to implement a new subclass of QAbstractItemView?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 23 Dec 2015, 08:00 last edited by
      #2

      implementing a custom QAbstractItemView is overkill in almost all situations :)

      A custom QItemDelegate may work, i am not sure if it will work with a QListView with setViewMode(QListView::IconMode).

      I would suggest you compose a custom widget. With QLabels for the headlines and a QListView with icon-mode set for the sub-items.
      You can then use stylesheets to hide the frame of the listview etc.
      To have a single selection across all the list views will be a bit tricky but possible.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • W Offline
        W Offline
        walkingTarget
        wrote on 23 Dec 2015, 18:50 last edited by
        #3

        I think I take your meaning. As I geared up to subclass QAbstractItemView, it also became evident how niche my new class would be. Based on this, I decided to take your advice of composing a custom widget.

        If anyone should want to subclass QAbstractItemView, this is a good article to get you started.

        1 Reply Last reply
        0

        2/3

        23 Dec 2015, 08:00

        • Login

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