Not to close Menu on MenuItem Click

  • Hi! I have a button with a menu like this:

    Button {
    	tooltip: qsTr("Filters")
    	style: ButtonStyle {
    		background: Rectangle {
    			implicitWidth: TextSingleton.pixelDeviceRatio * 24
    			implicitHeight: TextSingleton.pixelDeviceRatio * 24
    			x: control.pressed ? -1 : 0
    			y: control.pressed ? 1 : 0
    			color: "transparent"
    			Image {
    				anchors.fill: parent
    				source: control.hovered ? "qrc:///img/res/img/filters_w_hover.png" 
                                            : "qrc:///img/res/img/filters_w.png"
    				mipmap: true
    	menu: Menu {
    		id: filtersMenu
    		MenuItem {
    			id: menuItemTitle
    			text: qsTr("Title")
    			checkable: true
    			checked: false  
    		MenuItem {
    			id: menuItemDescription
    			text: qsTr("Description")
    			checkable: true
    			checked: false

    I would like the menu does not close when the items are clicked, to be able to select some filters without having to open the menu again.

  • Qt Champions 2017

    All normal main menus ever known to man, has always closed when you choose an item.
    So are u sure a menu is the right way of selecting filters ?

  • @mrjj For example, in many programs, when you are choosing toolbars, the rightmenu does not close what allows to choose some of them at once. I was thinking in implement the same.
    From your answer... I suppose there's no way to do it with Menu component, doesn't it?

  • Qt Champions 2017

    ok. never seen it then :)
    I would not rule out you can override it closing on menu selection by subclassing
    or using event filter.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.