qmenu

QMenuBar and QMenu doesn't show in Mac OS X

谁说我不能喝 提交于 2019-12-06 08:33:17
问题 I'm using Qt 4.7.4 on Mac OS X 10.7.4 , and I'm trying to add a QMenuBar and a QMenu to my application without success. When looking for examples, I found the Basic Layouts and the screenshot of the interface on Windows displays the File menu, which is what I'm trying to do: However , running this example on Mac OS X doesn't show the File menu inside the application window: and it also doesn't show in the top Mac OS X bar: It seems that this is either a bug of Qt 4.7.4 on Mac OS X, or we are

Aligning QMenuBar items (add some on left and some on right side)

为君一笑 提交于 2019-12-06 02:58:40
问题 Currently I have QMenuBar with three QActions and it looks like this: but I would like to get this (get some QActions right-aligned): Is there a way to do this? 回答1: Well one possible solution is here. But it involves implementing your own style (QStyle as I recall). However here is a snippet that I have just tried on mainwindow class: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QMenuBar *barLeft = new QMenuBar; QMenuBar *barRight

Custom Qt QMenu

主宰稳场 提交于 2019-12-05 04:00:56
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 QMenu , are there guides to produce similar results (perhaps by having a more standard widget act as a context menu) anywhere? Sure there is! In Qt, if there is a a will there is a way. You will probably need to make your own class that uses QMenu and uses a member QListWidget . You will then need to generate the layout and overload all the correct

Qt: Change application QMenuBar contents on Mac OS X

Deadly 提交于 2019-12-04 16:53:45
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 expected with the first and third style (haven't tested second, but I'd rather not use that style) on all platforms except for Mac OS X. The first menu is created in the way I create most in the application, and they receive the correct title, but disappear as soon as the menu is re-created. The second menu appears both on the initial population and the re

QMenuBar and QMenu doesn't show in Mac OS X

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 12:05:33
I'm using Qt 4.7.4 on Mac OS X 10.7.4 , and I'm trying to add a QMenuBar and a QMenu to my application without success. When looking for examples, I found the Basic Layouts and the screenshot of the interface on Windows displays the File menu, which is what I'm trying to do: However , running this example on Mac OS X doesn't show the File menu inside the application window: and it also doesn't show in the top Mac OS X bar: It seems that this is either a bug of Qt 4.7.4 on Mac OS X, or we are required to do some tweaks on the source code to make it work on Mac. How can I fix this problem? I've

Set position (to right) of Qt QPushButton popup menu

倖福魔咒の 提交于 2019-12-03 16:14:33
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"); ui->pushButtonMode->setMenu(menuMode); //I am writing in MainWindow, that's there is ui This can be

Menubar/ System tray app with Qt

风格不统一 提交于 2019-12-03 15:16:49
问题 I am new in Qt (PyQt) and I am trying to make an app whose functions will be executed from menubars/system trays. A perfect example is show here: I cannot find a good resource on how I can do this. Can someone advice. Thanks. 回答1: I think you are looking for working with QMenu and QMainWindow for the menu part, at least. Here you can find a C++ example: Menus Example and here a PyQt4 example: Menus and Toolbars in PyQt4 Here is the code inline for your convenience: import sys from PyQt4

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

こ雲淡風輕ζ 提交于 2019-12-03 12:06:55
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! pnezis 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* pWidget = new QWidget (NULL); QHBoxLayout* pLayout = new QHBoxLayout(); QLabel* pLabel = new QLabel

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

一世执手 提交于 2019-12-03 06:27:57
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? Probably this question is not relevant for question owner, but I suppose it could be helpful for others. Unlike QToolBar , QMenu doesn't have method widgetForAction . I found a simple workaround for this case. Try popup menu with QTest::mouseClick if nothing happens try to use QTest::keyClick(..., first_char_in_menu_tite, Qt::AltModifier) . To simulate action execution you can navigate

Menubar/ System tray app with Qt

谁说胖子不能爱 提交于 2019-12-03 05:06:13
I am new in Qt (PyQt) and I am trying to make an app whose functions will be executed from menubars/system trays. A perfect example is show here: I cannot find a good resource on how I can do this. Can someone advice. Thanks. I think you are looking for working with QMenu and QMainWindow for the menu part, at least. Here you can find a C++ example: Menus Example and here a PyQt4 example: Menus and Toolbars in PyQt4 Here is the code inline for your convenience: import sys from PyQt4 import QtGui class Example(QtGui.QMainWindow): def __init__(self): super(Example, self).__init__() self.initUI()