qaction

Why is PyQt executing my actions three times?

守給你的承諾、 提交于 2019-12-12 08:11:32
问题 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 super(MainWindow, self).__init__() #Load the interface self.ui = uic.loadUi(r"Form Files/rsleditor.ui") #Show the ui self.ui.show() and when I wanted to override the close event with: def closeEvent(self, event): quit_msg = "Are you sure you want to exit the program?" reply =

How to access a QAction using the QtTest lib?

蹲街弑〆低调 提交于 2019-12-12 04:22:43
问题 I have a pop-up menu in a QTableWidget (resultTable). In the constructor of my class I set the context menu policy: resultTable->setContextMenuPolicy(Qt::CustomContextMenu); connect(resultTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(popUpMenuResultTable(QPoint))); The popUpMenuResultTable function: void MyClass::popUpMenuResultTable(QPoint pos) { QMenu menu; QAction* actionExport = menu.addAction(QIcon(":/new/prefix1/FileIcon.png"), tr("Export")); connect(actionExport, SIGNAL

QAction parent menu

ぃ、小莉子 提交于 2019-12-12 02:38:57
问题 How to get parent menu of a given QAction? I have a QActions added to submenus. Is there any way to know parent menu name of each action? ui->action567->parent() //return MainWindow ui->action567->parentWidget() //return MainWindow ui->action567->menu() //return nullptr. ui->action567->actionGroup() //return nullptr. I can get parent menu this way: for( QMenu * menu : ui->menuBar->findChildren< QMenu * >() ) { if( menu->actions().contains( ui->action567 ) ) { qDebug() << menu << ui->action567

QAction toggling is hinder by QMenu mousePressEvent

左心房为你撑大大i 提交于 2019-12-11 18:44:04
问题 I have a nested menu items in which I am trying to make all of the items checkable. Initially the toggling is not working for the main item (a QMenu that is set as a QAction), while it works for sub items. But upon the use of mousePressEvent , the toggling now works for the main item but not for the sub items. Tried to replicate what I have done for main item for the sub item function, but the toggling still does not work. And seemingly, it is called twice in the _callActionItem() . However,

How can I get trigger signal for disabled QAction element?

孤人 提交于 2019-12-11 02:08:58
问题 I have disabled QAction menu element: QAction *item = new QAction(itemTitle); item->setEnabled(false); I use SLOT connection to call function after element was pressed, but it's works only for enabled elements: QObject::connect(item, SIGNAL(triggered()), this, SLOT(func())); My question is how can I trigger some function for disabled QAction element ? Qt 5.9.2, MSVC2017 64bit compiler 回答1: setEnabled() property holds whether the widget is enabled. In general an enabled widget handles keyboard

How to perform action on clicking a QMenu object only?

好久不见. 提交于 2019-12-10 10:23:11
问题 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 tried, but I got an empty output. mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QDebug> #include <QSignalMapper> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public:

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

最后都变了- 提交于 2019-12-08 15:53:45
问题 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 SuperHeaverExpertMenus initially, on program start, because it conatins a lot of settings, which might confuse beginner users. I want to show that sub tree with SuperHeavyExpertMenu , when a checkbox in Settings is true, for instance. I can hide the children QActions of

Subclassing matplotlib NavigationToolbar throws error with Pan / Zoom

对着背影说爱祢 提交于 2019-12-08 13:27:04
问题 I'm developing a GUI based filter design and analysis tool (https://github.com/chipmuenk/pyFDA), subclassing matplotlib NavigationToolbar to implement some changes (added / deleted functions and buttons, new icon set). The full code is available under https://github.com/chipmuenk/pyFDA/ . Each (tabbed) plot_* widget instantiates a copy of the subclassed NavigationToolbar, e.g. from plot_widgets/plot_phi.py : from plot_widgets.plot_utils import MplWidget class PlotPhi(QtGui.QMainWindow): def _

Why is PyQt executing my actions three times?

こ雲淡風輕ζ 提交于 2019-12-03 15:49:20
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 super(MainWindow, self).__init__() #Load the interface self.ui = uic.loadUi(r"Form Files/rsleditor.ui") #Show the ui self.ui.show() and when I wanted to override the close event with: def closeEvent(self, event): quit_msg = "Are you sure you want to exit the program?" reply = QtGui.QMessageBox.question(self, 'Message', quit_msg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if