Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Prevent Menu from closing when clicking a MenuItem in Quick Controls 2



  • Hi,

    I've been searching this for a while now, and I couldn't find a solution yet.
    I'm trying to create a nested menu, which has multiple MenuItems as children, using Quick Controls v2.
    I'm able to do this without any issue.

    This menu is supposed to be a set of filters to be applied to my data.
    All of this works perfectly, except for one User Experience issue: Whenever a MenuItem is clicked, the whole menu is dismissed. I want the menu to stay open - so the user can select multiple items without needing to navigate through the nested menu - until the user decides to click outside of it, to effectively close it.

    How is that possible?

    I've tried to search for signal overriding for clicks on QML, but I couldn't find anything about it.
    I also saw the C++ code for it, but I couldn't find where the menu is dismissed (I see it's probably on QQuickAbstractButtonPrivate::trigger(), but I couldn't follow the signals).

    I'd appreciate if you guys could give me a snippet that can do that, or instructions on how to tackle this problem.

    Thanks in advance!


  • Qt Champions 2018

    I'd say use a Popup instead of a Menu



  • Using a popup would force me to recreate the entire logic of Menu, including nested menus, right?

    Is there a simpler way to do that?

    If not, can you provide an example of how to implement nested menus using a popup, as a base?


Log in to reply