qmenu

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 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,

QAction won't connect to my slot

梦想与她 提交于 2019-12-11 17:18:35
问题 I'm trying to make an IHM with Qt, and I started by making a basic menu (File,Edit...). So far, I have my menu containing "File", which then display "New Project, Open Project, Exit". Look great, but my problem is I can't seem to trigger these Action (clicking them or by key shortcut). Here is my slot: void KoriganEngine::launchNewProjectWidget(){ //External QWidget m_nwProj = new NewProjectWidget(NULL,Qt::MSWindowsFixedSizeDialogHint); m_nwProj->show(); } If I use this slot with a pushbutton

How to show the menu in QPushButton without blocking?

一曲冷凌霜 提交于 2019-12-11 12:42:28
问题 I use Qt4 QPushButton with QMenu in it (set by setMenu() ). I need to show this menu when some unrelated event occurs. Method QPushButton::showMenu() does this, but it blocks until user closes the menu. QMenu::show() also does this, but it shows the menu in the top left corner of the screen. How can I programmatically make the menu show up properly positioned, and without blocking? 回答1: QMenu is QWidget . So you can call move() before show() . 回答2: You can use void QMenu::popup ( const QPoint

How to add check/Uncheck QAction in the context menu?

浪子不回头ぞ 提交于 2019-12-10 13:31:25
问题 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? 回答1: Here is the relevant section from the manual. checkable : bool This property holds whether the action is a checkable action. A checkable action is one which has an on/off state. For example, in a word processor, a Bold toolbar button may be either on or off. An

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:

Set position (to right) of Qt QPushButton popup menu

╄→尐↘猪︶ㄣ 提交于 2019-12-09 12:55:47
问题 I am writing a popup menu for a Qt push button widget. Whenever the push button is clicked, a menu pops up (below the push button). The popup menu is left-sided below by default. Are there any ways to make the popup menu to pop up on the right side below the push button? There is no set position function, so I wonder if there is some sophisticated way of doing it? Here is some code (for popup menu): QMenu *menuMode = new QMenu(this); min = menu ->addAction("In"); mout = menu ->addAction("out"

pyqt dynamic generate QMenu action and connect

╄→гoц情女王★ 提交于 2019-12-09 12:54:10
问题 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 MainForm(QtGui.QMainWindow): def __init__(self, parent=None): super(MainForm, self).__init__(parent) # create button self.button = QtGui.QPushButton("test button", self) self.button.resize(100, 30) # set button context menu policy self.button.setContextMenuPolicy(QtCore.Qt

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

淺唱寂寞╮ 提交于 2019-12-09 09:58:33
问题 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! 回答1: You have to subclass QWidgetAction and then simply call the addAction to your menu. Example code for Spin Box Action with a label class SpinBoxAction : public QWidgetAction { public: SpinBoxAction (const QString& title) : QWidgetAction (NULL) { QWidget*

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