Questions tagged [qaction]

The QAction class, part of the Qt framework, provides an abstract user interface action that can be inserted into widgets.

Documentation can be found here

145 questions
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
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
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
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

Create QAction with shortcut, without inserting in menu

#include "mainwindow.h" #include "ui_mainwindow.h" #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QAction* back = new QAction(this); …
Ashot
  • 10,807
  • 14
  • 66
  • 117
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

Why is PyQt executing my actions three times?

I'm still kind of new to PyQt but I really have no idea why this is happening. I have a Mainwindow that I create like this: class MainWindow(QtGui.QMainWindow): #initialize def __init__(self): #Call parent constructor …
SketchyManDan
  • 176
  • 1
  • 10
5
votes
2 answers

How to use QTest::mouseClick with QAction

I'm very new to Qt, and I need to simulate a click using the QTest Namespace and QTest::mouseClick. My problem is I would like to click a QMenu entry, defined as a QAction, but the mouseClick function doesn't allow me to pass this as an argument…
Fran M.
  • 79
  • 5
4
votes
1 answer

How to change the icon of an action in the toolbar at runtime?

I want to change QAction's icon in Toolbar when it is clicked. I have seen the same question in C++, but it's hard to me to understand other languages. (On Qt, how to change the icon of an action in the toolbar at runtime?) import sys from…
Gunter-R
  • 85
  • 1
  • 5
4
votes
2 answers

Qt connect QAction to function with arguments

In my Qt 5.6 program I need to connect QMenu Click (QAction) to function and provide some arguments. I can connect to function without arguments and it is working: connect(MyAction, &QAction::triggered, function); But, when I'm trying to add some…
km2442
  • 779
  • 2
  • 11
  • 31
4
votes
1 answer

PyQt: How to load a url from a menu item

I have a main window with some buttons and a plot. I added a file menu, using Qt Designer. Now, if I run my app, everything is good and I can see a typical menu bar. The problem is, I want to click on the menu bar and perform an action - I want to…
Gianluca
  • 142
  • 1
  • 4
  • 13
4
votes
1 answer

In Qt app how to capture "Cmd-Q" or "Quit" menu click

In my Qt app, I have a quit routine which gracefully cleans up everything before finally quitting, else there might be a crash somewhere. The app runs in the system tray, and there is a "Quit" menu defined for the system tray icon. On the quitAction…
Soumya Das
  • 1,635
  • 2
  • 19
  • 28
4
votes
4 answers

PyQt: Can a QPushButton be assigned a QAction?

Using Python 3.2x and PyQT 4.8x: I initialized an action and assigned to a menu item: self.__actionOpen =…
Vector
  • 10,879
  • 12
  • 61
  • 101
3
votes
2 answers

Determine which Shortcut is pressed in Qt

I have a QAction which I've assigned multiple shortcuts to it test = new QAction(); this->addAction(test); QList shortcuts; shortcuts << QKeySequence(Qt::Key_N) << QKeySequence(Qt::Key_T); test->setShortcuts(shortcuts); …
Tamim Boubou
  • 75
  • 11
1
2 3
9 10