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
25
votes
4 answers

Is there a way to define a QToolbar with buttons and popup menus using Qt Designer?

I am wanting to have a toolbar in Qt that contains either QActions or QToolbarButtons that have popup menus attached to them. I have been able to do this perfectly in the code by creating a QMenu, adding it to a QToolbarButton and then adding that…
Eddie Loeffen
  • 251
  • 1
  • 3
  • 4
21
votes
4 answers

How to iterate through a menu's actions in Qt?

I'm working in a project where I need to open (show or popup) automatically the items in the QMenuBar. Let's say I have the next menu bar: File Edit Help -op1 -op1 -op1 -op2 -op2 -op2 To set an action (show…
Hermandroid
  • 2,120
  • 4
  • 29
  • 35
17
votes
3 answers

how to make qmenu item checkable pyqt4 python

How can i make my qmenu checkable? from PyQt4 import QtGui app = QtGui.QApplication([]) menu = QtGui.QMenu() menu.addAction('50%') menu.addAction('100%') menu.addAction('200%') menu.addAction('400%') menu.show() app.exec_()
unice
  • 2,655
  • 5
  • 43
  • 78
15
votes
2 answers

QTooltip for QActions in QMenu

I want to be able to show ToolTips for QMenu items (QActions). The best I have achieved is to connect the hovered signal of the QAction to a QTooltip show: connect(action, &QAction::hovered, [=]{ QToolTip::showText(QCursor::pos(), text,…
Noel
  • 730
  • 6
  • 15
15
votes
2 answers

Simple color fill QIcons in Qt

I need to create a menu that changes the background of a QWidget. I'd like to place a QIcon that represents the selected color into the QActions which populates the QMenu. I'd like to not have to pop out Photoshop and paint the icons manually. Is…
jliu83
  • 1,553
  • 5
  • 18
  • 23
14
votes
2 answers

QMenu item text disappears when icon added

I am attempting to add an icon to my QMenu using Qt Designer, however I realized that my text disappears when my icon is added. Is there any way for me to show my icon next to my text?
MistyD
  • 16,373
  • 40
  • 138
  • 240
13
votes
3 answers

How to add a list of QActions to a QMenu and handle them with a single slot?

First, I have a list of QWidgets that I won't know the length of until runtime. I then create a QListWidget where I show them and when someone clicks them I use the signal currentItemChanged(QListWidgetItem*, QListWidgetItem*) to catch it and get…
chikuba
  • 4,229
  • 6
  • 43
  • 75
12
votes
3 answers

Not possible to hide a QMenu object QMenu::setVisible()?

I have built up a QMenu MainMenu on top of my MainWindow in my application. As everybody is used to it, I have following QMenu Main menus: File - Edit - SuperHeavyExpertMenus - Settings - Help I would like to hide the sub tree…
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103
12
votes
4 answers

Why won't QToolTips appear on QActions within a QMenu

I'm doing an app with in GUI written with PySide. I set a QMenu on a QPushButton, added several QActions via QMenu.addAction. To further explain these actions to the user I added QToolTip's to these with QAction.setToolTip. When I run the GUI now my…
Max Belli
  • 167
  • 2
  • 7
11
votes
3 answers

Is there a way to add a QWidget to a QMenu in QtCreator

I'm creating a text editor and I'd like to put the QComboBox in the QMenu. I didn't find any method inside the QMenu that handled such a thing. The closest is QMenu::addAction(). I was wondering of getting around this hurdle. Thanks!
W.K.S
  • 9,787
  • 15
  • 75
  • 122
11
votes
2 answers

Qt UI testing: How to simulate a click on a QMenuBar item using QTest?

I am trying to simulate a mouse click on a QMenu item from a QMenuBar, for example clicking on "Save As" QAction using the QTestLib framework. I am triyng this under Windows XP 32 bit and Qt 5.0.2. Any Ideas?
Popovici Silviu
  • 111
  • 1
  • 3
9
votes
3 answers

Remove icon space from QMenu

I'm working on a Qt application (in C++). Without appyling any styles, my menu looks like this: I'd like it to look like this: How do I achieve this? Either using qss, or programmatically? I already tried this, without success: …
JoergEwald
  • 379
  • 3
  • 10
9
votes
3 answers

Custom Qt QMenu

Is there a way in Qt to add a layout or widgets to a QMenu to create a custom menu? The example below (left) is what I have, and I'd like to aim for something similar to the mock-up on the right, by adding non-menu widgets. If it can't be done by…
Kver
  • 767
  • 5
  • 19
8
votes
4 answers

Qt Stylesheets: How to apply style to menus? How to remove blue tinge around QTextEdit?

I am trying to make the menubar a gradient black colour and that works fine, except for the menu headings. Here's the stylesheet i'm using: QString styleSheet = "QMenuBar{background: qlineargradient(x1:0,x2:0,y1:0,y2:1,stop:0 #cccccc, stop:0.4…
W.K.S
  • 9,787
  • 15
  • 75
  • 122
8
votes
1 answer

Qt QMenu remove drop shadow

I have a QMenu with a translucent background and rounded edges (border-radius). Unfortunately, Windows 7 draws a drop shadow for this menu, which does not fit to the rounded edges. Its the shadow that would be drawn for normal rectangular menues. Is…
user1703711
  • 123
  • 2
  • 6
1
2 3
16 17