Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Hierarchical/Cascading QML Combobox?
Forum Updated to NodeBB v4.3 + New Features

Hierarchical/Cascading QML Combobox?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 529 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.
  • M Offline
    M Offline
    Morgan Liu-Packard
    wrote on last edited by
    #1

    Hello all.
    I've been tasked with implementing a hierarchical combobox in QML. This should behave like the attached image. Upon clicking the combobox button, a list will appear. List items with children will have an indicator next to them. Mousing over parent list items will reveal another list to the right.

    Questions:

    1. It seems likely someone has built this already. Are there any repositories of third-party components I should look at in order to find a ready-made component?
    2. Does this seem reasonably doable, using ComboBox (QtQuick.Controls 2.15) as a base type. Any chance I'll be able to do it without C++ work? The docs on customizing ComboBox don't give much help. There's some complicated / confusing stuff going on between the popup's contentItem (a list view), and the Combobox's delegate property, and the interaction between the popup's contentItem and the root ComboBox appears to be wired up on the C++ side.

    Many thanks for your help!

    -Morgan

    Screen Shot 2023-08-23 at 12.31.17 PM.png

    1 Reply Last reply
    0
    • jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #2

      That looks like what I think of as a menu rather than a combobox. The only significant distinction that comes to mind for me is that a combobox displays the last selected choice in its button, while a menu's button text tends not to change. That's something user code can explicitly set.

      Menu already supports submenus.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      M 1 Reply Last reply
      0
      • jeremy_kJ jeremy_k

        That looks like what I think of as a menu rather than a combobox. The only significant distinction that comes to mind for me is that a combobox displays the last selected choice in its button, while a menu's button text tends not to change. That's something user code can explicitly set.

        Menu already supports submenus.

        M Offline
        M Offline
        Morgan Liu-Packard
        wrote on last edited by
        #3

        @jeremy_k Thanks! Menu does look promising. One issue though -- I need to build the menu dynamically, with a nested model. I don't think Menu supports that. I can figure out how to build it (especially if I can figure out how to get Instantiator to instantiate different types based on whether the current model item is an item or another model), but also suspect someone else has already built it and wonder if there's an open source version of this somewhere already.

        1 Reply Last reply
        0
        • jeremy_kJ Offline
          jeremy_kJ Offline
          jeremy_k
          wrote on last edited by
          #4

          Menu.addAction(), addItem(), and addMenu() are also options for dynamic construction, if the imperative programming paradigm is easier to work with.

          Asking a question about code? http://eel.is/iso-c++/testcase/

          M 1 Reply Last reply
          0
          • jeremy_kJ jeremy_k

            Menu.addAction(), addItem(), and addMenu() are also options for dynamic construction, if the imperative programming paradigm is easier to work with.

            M Offline
            M Offline
            Morgan Liu-Packard
            wrote on last edited by
            #5

            @jeremy_k Thank you!

            1 Reply Last reply
            0

            • Login

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