Questions tagged [qmenu]

The QMenu class, part of the Qt framwork, provides a menu widget for use in menu bars, context menus, and other popup menus.

Documentation can be found here (Qt4) and here (Qt5).

252 questions
3
votes
0 answers

Difference between QWidget::grabKeyboard() and the grab done by QMenu

I noticed that while a QMenu is open, my key bindings stop working ( xbindkeys ), also screensavers can't start and report a "Can't grab keyboard" error. This doesn't happen with other QWidgets that use QWidget::grabKeyboard(). Does QMenu grab the…
Sergio Martins
  • 897
  • 2
  • 8
  • 18
3
votes
1 answer

connect a function when menu title is clicked

I am trying to find open ports and add them to my menu. Right now, what I succeed having an action to my menu (like, "find ports"), and only if it's clicked - it will connect to my function that gets all free ports. Unfortunately, that's not what I…
Alon123
  • 164
  • 3
  • 15
3
votes
2 answers

Signals or events for QMenu tear-off

Is there a signal/event I can make use of for the QMenu tear-off? I have a QMenu subclass in which it has .setTearOffEnabled(True), but I would like to set this tear-off to always be on the top if the user clicks on the tear-off 'bar'. I am unable…
dissidia
  • 1,531
  • 3
  • 23
  • 53
3
votes
1 answer

QWidgetAction : how to make the menu disappear after the user completes his input

In my QMenuBar, I have several menus. One of those menus has a QWidgetAction in it. It shows up fine, but the problem is that once the user completes his input, I want the menu to disappear (as is the normal behavior for a classical…
houbysoft
  • 32,532
  • 24
  • 103
  • 156
3
votes
1 answer

How to add actions menu in a toolbar?

I want to add a menu from an item in a toolbar. For example, from the following code: import sys from PyQt5.QtWidgets import QAction, QMainWindow, QApplication class Menu(QMainWindow): def __init__(self): super().__init__() …
TheCrystalShip
  • 249
  • 2
  • 4
  • 12
3
votes
1 answer

One QAction checkable at time in QMenu

I am trying to make my choices from QMenu to be checkable in a way that only one might be selected at time and first item is set checked by default (this works actually). Here is a snippet of my code: paymentType = QMenu('Payment Type',…
New2coding
  • 715
  • 11
  • 23
3
votes
1 answer

How to insert a special character into QMenu as a part of Title text?

I want to insert a special character '&' into a QMenu as a part of Titletext on windows with QT. How can i do it? If I put this character into a QMenu as Titletext through QMenu::setTitle() function, then I can not see the special character. The…
kleinstein
  • 33
  • 3
3
votes
1 answer

PySide\PyQt - Menu Add Action at index (before or between)

I'm creating a custom context menu for a widget in PySide, and I want to preserve Standard menu options, but I want to put them after custom actions. Is there a way to add actions to QMenu and set specific order for them? Here's my current code: def…
Nix
  • 465
  • 1
  • 7
  • 16
3
votes
3 answers

How to resize a QLabel displayed by a QWidgetAction after changing it's text

I use a QWidgetAction to add a header to a context menu (that will also show up on Windows, no matter what style is used, in contrast to addSection(), which does not always actually display the title). The action's widget is a QLabel. It's text is…
Tobias Leupold
  • 1,512
  • 1
  • 16
  • 41
3
votes
1 answer

How to execute a function when a tray icon menu action is pressed?

int main( int argc, char* argv[] ) { QApplication oApp( argc, argv ); QAction *action1; QMenu menu; QSystemTrayIcon TrayIcon( QIcon("favicon.ico") ); TrayIcon.show(); action1= new QAction("action1", NULL); …
stefan
  • 133
  • 1
  • 1
  • 6
3
votes
1 answer

Qt 5.4 OS X how to use a QAction in both a QMenu and a QToolBar, but show the icon only in the QToolbar

Using Qt 5.4 on OS X (Yosemite), I have a QAction that has an icon. I want the icon to show in the QToolbar that I add the action to. This works fine. However, I do NOT want the icon to show in the QMenu that I add the action to. How do I do…
David Burson
  • 2,947
  • 7
  • 32
  • 55
3
votes
2 answers

Qt: Change application QMenuBar contents on Mac OS X

My application uses a QTabWidget for multiple 'pages', where the top-level menu changes depending on what page the user is on. My issue is that attempting to re-create the contents of the menu bar results in major display issues. It works as…
syrius
  • 31
  • 1
  • 6
3
votes
1 answer

PyQt Context Menu Shortcut

I'm having trouble understanding the shortcut functionality of a QAction added to a QMenu. Lets start with an example: from PyQt4 import QtCore, QtGui import sys class TestApp(QtGui.QMainWindow): def __init__(self, *args): …
voocoder
  • 31
  • 1
  • 2
3
votes
2 answers

Working with a QMenu and passing of arguments

I have a QMenuwhich has several menu items built dynamically. To this end, I iterate over a collection of menu items, containing the name and Action ( which would need to be taken if the menu item were hit), and keep adding them to a the context…
user1173240
  • 1,455
  • 2
  • 23
  • 50
2
votes
1 answer

PyQt QMenu dropdown direction

I'm looking for a way to control the direction that sub-menus are opened from in a QMenu. The default behavior is to open to the right, unless there isn't enough screen real estate, then open to the left. If you have a menu that's on the far right…
guyincognito
  • 203
  • 3
  • 6