The QMenu class, part of the Qt framwork, provides a menu widget for use in menu bars, context menus, and other popup menus.
Questions tagged [qmenu]
252 questions
7
votes
2 answers
highlighting custom QWidgetAction on hover
My application has a QMenuBar with a number of QMenus, each of which having a number of QActions and sub-QMenus.
Most of the QAction-items are derivatives of QWidgetAction with re-implemented QWidgetAction::createWidget methods.
Usually, both…

pasbi
- 2,037
- 1
- 20
- 32
7
votes
2 answers
I want to know if QAction is clicked by left or right mouse button
I have a QAction in QMenu. When QAction is triggered() I would like to know which button did it.
connect(YourAction, SIGNAL(triggered()), this, SLOT(actionclicked()));
void MainWindow::actionclicked(QMouseEvent *e)
{
if (e->buttons() ==…
user6285273
7
votes
5 answers
Non interactive items in QMenu
I'm trying to build a menu with some items that are not interactive in QT. I subclass QMenu in my MyCustomMenuClass. I'm trying to add section titles to my menu so that it's clearer for the user.
For example, it should look like this:
My section 1…

abousquet
- 576
- 3
- 13
7
votes
2 answers
How to perform action on clicking a QMenu object only?
Here's a snapshot of the GUI. I want to perform simple actions solely by clicking on QMenu object Help. This QMenu object does NOT have any submenus.
Can you please advise me how to perform actions when only the QMenu is clicked
Here's what I have…

cappy0704
- 557
- 2
- 9
- 30
7
votes
1 answer
adding submenu in pyqt QWidget
I know its very basic question but I am little bit confused, probably I am forgetting something.
I am trying to add a sub menu "Preview" to the "Tools" in the QMenuBar()
so far this is what I am trying to do
tools =…

Ciasto piekarz
- 7,853
- 18
- 101
- 197
6
votes
2 answers
Aligning QMenuBar items (add some on left and some on right side)
Currently I have QMenuBar with three QActions and it looks like this:
but I would like to get this (get some QActions right-aligned):
Is there a way to do this?

xx77aBs
- 4,678
- 9
- 53
- 77
6
votes
1 answer
Why QMenu's separator doesn't show text?
My goal is to make menu with labeled separators.
So, I am running this code:
QMenu *menu = new QMenu;
QAction *group1 = menu->addSeparator();
group1->setText("Group of actions #1");
menu->addAction("Action #1");
menu->addAction("Action…

Rinat
- 1,941
- 2
- 17
- 26
6
votes
1 answer
How to programmatically close QMenu
I have pretty specific situation. I want to place a QAction into QToolbar and reach following behaviour:
Checkable QAction with icon.
Classic arrow on the right side which is used for showing menu
By pressing this arrow my QDialog should appears on…

tema
- 1,115
- 14
- 33
6
votes
3 answers
pyqt dynamic generate QMenu action and connect
Still learning how pyqt works. I want to dynamically generate a customContextMenu and connect with a function. So far I got the following but the connect part not working ?
import sys
from PyQt4 import QtGui, QtCore
class…

moDong
- 223
- 2
- 5
- 9
6
votes
1 answer
How to pass a QString to a Qt slot from a QMenu via QSignalMapper or otherwise
I have a QMenu with many submenus. These are dynamically created i.e. the names menus come from a db and created in a loop. Now i wanted to fire the same slot triggered() or similar when a menu is clicked, but i needed the QString menu name to be…

fkl
- 5,412
- 4
- 28
- 68
6
votes
1 answer
How to add check/Uncheck QAction in the context menu?
I have created a context menu in Qt and I need the items in the menu works in a checked/Unchecked manner so that it toggles for every click on the respective item. How to add this feature to the QAction just like shown below?

indira
- 6,569
- 18
- 65
- 80
5
votes
1 answer
Ownership of QAction
When adding a QAction* to a QMenu who is responsible for deleting the QAction* object? I couldn't find it mentioned in the documentation for QMenu or QAction.
void MyClass::contextMenuEvent(QContextMenuEvent *evt)
{
QMenu menu(this);
QAction…

glennr
- 2,069
- 2
- 26
- 37
5
votes
4 answers
Qt system tray context menu remains when app loses focus
I've set up a system tray icon for my app and have attached a simple context menu to it. If I right click the icon to bring up the context menu it works fine. If I then click somewhere that loses the focus of the app (e.g. elsewhere on the task…

Rok
- 2,568
- 4
- 26
- 28
5
votes
1 answer
How to include tooltips for menu items in qt
I'm trying to add ToolTips on MenuBar Items using the tool properties but it didn't work... But on labels, pushbuttons and other widgets it seems to work pretty fine. Can anyone help me with this?
user12991669
5
votes
1 answer
How to get the name of a QMenu Item when clicked?
I have a few actions in a QMenu that I'm trying to connect to a single method; there are additional actions that are unrelated.
import sys
from PyQt5.QtWidgets import *
class Window(QWidget):
def __init__(self):
super(Window,…

artomason
- 3,625
- 5
- 20
- 43