Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

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.


  • Lifetime Qt Champion

    Hi
    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?


  • Lifetime Qt Champion

    @ars1614
    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