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. QComboBox with groups?
Qt 6.11 is out! See what's new in the release blog

QComboBox with groups?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 854 Views 1 Watching
  • 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.
  • D Offline
    D Offline
    Dan203
    wrote on last edited by
    #1

    Is there an easy way to add subcategories to a QComboBox's drop down? Something like this...

    5979f43a-2cb3-4cb4-ac6f-6b4cc9eea041-image.png

    JonBJ 1 Reply Last reply
    0
    • D Dan203

      Is there an easy way to add subcategories to a QComboBox's drop down? Something like this...

      5979f43a-2cb3-4cb4-ac6f-6b4cc9eea041-image.png

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Dan203
      Not that I know of. You would have to roll your own code. A QComboBox uses a QListView for the items:

      QComboBox uses the model/view framework for its popup list and to store its items. By default a QStandardItemModel stores the items and a QListView subclass displays the popuplist.

      and that does not support these "categories". You might be able to use setView() (and maybe setModel()) to introduce your own view, with either your own layout (QStyledItemDelegate) and/or perhaps a QTreeView.

      1 Reply Last reply
      2

      • Login

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