QToolButton don't hide popup menu after triggering action - qt

I have a QToolButton with a popup menu on a toolbar. Popup menu has a number of checkable actions, and it looks like this:
Problem is - popup menu closes every time I check/uncheck the action, but I want it to stay opened so I can check a number of actions with no need to reopen popup menu. How can I achieve this?
Edited:
Found this workaround - Prevent a QMenu from closing when one of its QAction is triggered
It looks a bit different but still ok for me:

Related

Close all ContextMenu with mouse button

Is there a way to close all opened context menus opened on the scene?
When I press a button I would like to close all Context menus opened by right muse click.
Sure, just have some data structure, say a Stack<ContextMenu> Where every time you make a context menu, you push it on the stack, and every time you hide it, you pop it off the stack. Then when you press a certain button, just iterate through the stack and call the .hide() method of contextMenu, on each item i the stack, hiding them as you go, and voila! that should do it.

How to use Panel as Button Menu in Sencha Architect?

PROGRAMS USED: Sencha Architect with ExtJS 4.2.
CURRENT SITUATION: My Button use a Start Menu style. The Start Menu is Panel type. I put both the Button and the Start Menu Panel in a Taskbar. Since I can't point the Button to use the Panel as a Menu in Architect (it automatically creates a Menu type when I click create Menu), so I use this code in the Taskbar afterLayout event:
container.getComponent('StartButton').menu = container.getComponent('StartMenuView');
PROBLEMS: The StartMenu displayed correctly when I click the Button, but I can't close it no matter where I click. What did I miss? Any help is appreciated.
Decided to switch to another much simpler approach that I've just figured: Use my "StartMenu" Panel as a Menu Item in my "Start" Button.

Show context menu of QSystemTrayIcon without user click

I have a QSystemTrayIcon, that displays a QMenu on click, but I want to display the menu as soon as the tray icon is displayed. I have tried calling the show method on the QMenu, but the menu only seems to display when it is clicked. Any idea on how to change this behaviour?
I'm not sure if it's possible to trigger the behaviour triggered by operating system when user clicks the system tray, but at least you should be able to use QMenu::popup method to just show the menu returned by QSystemTrayIcon::contextMenu method.
Note that you should use the menu's size hint, when you calculate the menu postion relative to QSystemTrayIcon::geometry. Also you may need to use QDesktopWidget::availableGeometry to make sure the menu pops up inside the screen, no matter where the task bar is.

What is the proper name for a multibutton?

I'm trying to design a UI in Qt and I can't find anywhere in the designer a button which can be "droped down" like combobox. What I mean by that is that I would like to have this button with his "default" option choosen so if I like it I would have to just click on it but if I would like to choose different option I would be able to clik the little arrow on the right side of this button and then pick option suitable for me at that moment.
You're looking for a QToolButton that has a set of actions or a menu set on it. From the documentation, the QToolButton::ToolButtonPopupMode...
Describes how a menu should be popped up for tool buttons that has a menu set or contains a list of actions.
Of it's values, the two that I see most frequently are DelayedPopup:
After pressing and holding the tool button down for a certain amount of time (the timeout is style dependant, see QStyle::SH_ToolButton_PopupDelay), the menu is displayed. A typical application example is the "back" button in some web browsers's tool bars. If the user clicks it, the browser simply browses back to the previous page. If the user presses and holds the button down for a while, the tool button shows a menu containing the current history list
And MenuButtonPopup:
In this mode the tool button displays a special arrow to indicate that a menu is present. The menu is displayed when the arrow part of the button is pressed.

Flex - Menu Created On Button Click

I created a Button in MXMXL. On button click, I create a Menu as a child of the Button. I am using an XML datasource. The reason for creating it this way, was due to the amount of custom skinning involved. A popupmenubutton was not an option. Anyway, so my question is this: when clicking the button, the menu is displayed. However, if you click the button again, the menu reopens. I want the menu to close if the user clicks the button a second time. Now, I got it to work by setting a var after opening the menu, and then I check that var on each click to make sure that the menu isn't already open. If true, then it will close the menu, instead of reopening it. This works, until the user clicks away, in which the HIDE event gets dispatched and the menu closes. My hack no longer works.
Any suggestions? I spent hours trying different things. The hardest part is trying to destinguish from that second button click when the menu is open, and when the user clicks away from the menu. They both dispatch the HIDE event.
Help!!!
Have you tried adding another eventlistener to the button...FlexMouseEvent.MOUSE_DOWN_OUTSIDE ? You should then be able to set the preventDefault event to true to stop the event from firing anything else and stop the menu from closing.

Resources