QMenuBar Class Reference |
The Plastique widget style, like most other styles, handles the Help menu in the same way as it handles any other menu. | |
The Motif widget style treats Help menus in a special way, placing them at right-hand end of the menu bar. |
QMenuBar on Qt/Mac is a wrapper for using the system-wide menubar. If you have multiple menubars in one dialog the outermost menubar (normally inside a widget with widget flag Qt::Window) will be used for the system-wide menubar.
Qt/Mac also provides a menubar merging feature to make QMenuBar conform more closely to accepted Mac OS X menubar layout. The merging functionality is based on string matching the title of a QMenu entry. These strings are translated (using QObject::tr()) in the "QMenuBar" context. If an entry is moved its slots will still fire as if it was in the original place. The table below outlines the strings looked for and where the entry is placed if matched:
String matches | Placement | Notes |
---|---|---|
about.* | Application Menu | About <application name> | If this entry is not found no About item will appear in the Application Menu |
config, options, setup, settings or preferences | Application Menu | Preferences | If this entry is not found the Settings item will be disabled |
quit or exit | Application Menu | Quit <application name> | If this entry is not found a default Quit item will be created to call QApplication::quit() |
You can override this behavior by using the QAction::menuRole() property.
If you wish to make all windows in a Mac application share the same menubar, you need to create a menu bar that does not have a parent. The menubar is created like this:
QMenuBar *menuBar = new QMenuBar(0);
Note: The text used for the application name in the menu bar is obtained from the value set in the Info.plist file in the application's bundle. See Deploying an Application on Qt/Mac for more information.
The Menus example shows how to use QMenuBar and QMenu. The other main window application examples also provide menus using these classes.
See also QMenu, QShortcut, QAction, Introduction to Apple Human Interface Guidelines, GUI Design Handbook: Menu Bar, and Menus Example.
This property holds the popup orientation.
The default popup orientation. By default, menus pop "down" the screen. By setting the property to true, the menu will pop "up". You might call this for menus that are below the document to which they refer.
If the menu would not fit on the screen, the other direction is used automatically.
Access functions:
Constructs a menu bar with parent parent.
Destroys the menu bar.
Returns the QAction that is currently highlighted. A null pointer will be returned if no action is currently selected.
See also setActiveAction().
This convenience function creates a new action with text. The function adds the newly created action to the menu's list of actions, and returns it.
See also QWidget::addAction().
This is an overloaded member function, provided for convenience.
This convenience function creates a new action with the given text. The action's triggered() signal is connected to the receiver's member slot. The function adds the newly created action to the menu's list of actions and returns it.
See also QWidget::addAction().
Appends menu to the menubar. Returns the menu's menuAction().
See also QWidget::addAction() and QMenu::menuAction().
This is an overloaded member function, provided for convenience.
Appends a new QMenu with title to the menubar. The menubar takes ownership of the menu. Returns the new menu.
See also QWidget::addAction() and QMenu::menuAction().
This is an overloaded member function, provided for convenience.
Appends a new QMenu with icon and title to the menubar. The menubar takes ownership of the menu. Returns the new menu.
See also QWidget::addAction() and QMenu::menuAction().
Appends a separator to the menu.
Removes all the actions from the menu bar.
See also removeAction().
This signal is emitted when a menu action is highlighted; action is the action that caused the event to be sent.
Often this is used to update status information.
See also triggered() and QAction::hovered().
This convenience function inserts menu before action before and returns the menus menuAction().
See also QWidget::insertAction() and addMenu().
This convenience function creates a new separator action, i.e. an action with QAction::isSeparator() returning true. The function inserts the newly created action into this menubar's list of actions before action before and returns it.
See also QWidget::insertAction() and addSeparator().
Sets the currently highlighted action to act.
This function was introduced in Qt 4.1.
See also activeAction().
This signal is emitted when a menu action is selected; action is the action that caused the event to be sent.
Normally, you connect each menu action to a single slot using QAction::triggered(), but sometimes you will want to connect several items to a single slot (most often if the user selects from an array). This signal is useful in such cases.
See also hovered() and QAction::triggered().
Constant | Value |
---|---|
QMenuBar::Never | 0 |
QMenuBar::InWindowsStyle | 1 |
Use one of the constructors that doesn't take the name argument and then use setObjectName() instead.
Use shortcut() on the relevant QAction instead.
See also setAccel().
Use activate() on the relevant QAction instead.
Use triggered() instead.
Returns true if the menu bar automatically resizes itself when its parent widget is resized; otherwise returns false.
This feature is provided to help porting to Qt 4. We recommend against using it in new code.
See also setAutoGeometry().
Use setText() on the relevant QAction instead.
This is an overloaded member function, provided for convenience.
Use setText() on the relevant QAction instead.
This is an overloaded member function, provided for convenience.
Use setIcon() and setText() on the relevant QAction instead.
Use connect() on the relevant QAction instead.
Use actions().count() instead.
Use disconnect() on the relevant QAction instead.
Use actions instead.
Use style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, this) instead.
Use hovered() instead.
Use icon() on the relevant QAction instead.
Use actions instead.
Use actions().indexOf(action) on the relevant QAction instead.
Use one of the insertAction() or addAction() overloads instead.
This is an overloaded member function, provided for convenience.
Use one of the insertAction() or addAction() overloads instead.
This is an overloaded member function, provided for convenience.
Use one of the insertAction(), addAction(), insertMenu(), or addMenu() overloads instead.
This is an overloaded member function, provided for convenience.
Use one of the insertAction() or addAction() overloads instead.
This is an overloaded member function, provided for convenience.
Use one of the insertAction(), addAction(), insertMenu(), or addMenu() overloads instead.
This is an overloaded member function, provided for convenience.
Use one of the insertMenu(), or addMenu() overloads instead.
This is an overloaded member function, provided for convenience.
Use one of the insertMenu(), or addMenu() overloads instead.
This is an overloaded member function, provided for convenience.
Use one of the insertAction(), addAction(), insertMenu(), or addMenu() overloads instead.
This is an overloaded member function, provided for convenience.
Use one of the insertMenu(), or addMenu() overloads instead.
This is an overloaded member function, provided for convenience.
Use addSeparator() or insertAction() instead.
For example, if you have code like
menuBar->insertSeparator();
you can rewrite it as
menuBar->addSeparator();
This function was introduced in Qt 4.2.
Use activeAction() instead.
Use isChecked() on the relevant QAction instead.
Use isEnabled() on the relevant QAction instead.
Use isVisible() on the relevant QAction instead.
There is no equivalent way to achieve this in Qt 4.
Use QAction::data() instead.
See also setItemParameter().
Use actionGeometry() on the relevant QAction instead.
Returns the with of the the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
See also setMargin() and QWidget::getContentsMargins().
Use QPixmap(icon()) on the relevant QAction instead.
Use removeAction() instead.
Use removeAction() instead.
This function is provided only to make old code compile.
See also setSeparator().
Use setShortcut() on the relevant QAction instead.
See also accel().
Sets whether the menu bar should automatically resize itself when its parent widget is resized.
This feature is provided to help porting to Qt 4. We recommend against using it in new code.
See also autoGeometry().
Use setChecked() on the relevant QAction instead.
See also isItemChecked().
Use setEnabled() on the relevant QAction instead.
See also isItemEnabled().
Use QAction::setData() instead.
See also itemParameter().
Use setVisible() on the relevant QAction instead.
See also isItemVisible().
Sets the width of the margin around the contents of the widget to margin.
Use QWidget::setContentsMargins() instead.
See also margin() and QWidget::setContentsMargins().
This function is provided only to make old code compile.
See also separator().
Use setWhatsThis() on the relevant QAction instead.
See also whatsThis().
Use text() on the relevant QAction instead.
Use whatsThis() on the relevant QAction instead.
See also setWhatsThis().
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.2 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com