Hierarchical/Cascading QML Combobox?
-
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:
- 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?
- 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
-
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.
-
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.
@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.
-
Menu.addAction(), addItem(), and addMenu() are also options for dynamic construction, if the imperative programming paradigm is easier to work with.
-
Menu.addAction(), addItem(), and addMenu() are also options for dynamic construction, if the imperative programming paradigm is easier to work with.
@jeremy_k Thank you!