Qt 4.8
|
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus. More...
#include <qmenu.h>
Signals | |
void | aboutToHide () |
This signal is emitted just before the menu is hidden from the user. More... | |
void | aboutToShow () |
This signal is emitted just before the menu is shown to the user. More... | |
void | hovered (QAction *action) |
This signal is emitted when a menu action is highlighted; action is the action that caused the signal to be emitted. More... | |
void | triggered (QAction *action) |
This signal is emitted when an action in this menu is triggered. More... | |
Signals inherited from QWidget | |
void | customContextMenuRequested (const QPoint &pos) |
This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
QAction * | actionAt (const QPoint &) const |
Returns the item at pt; returns 0 if there is no item there. More... | |
QRect | actionGeometry (QAction *) const |
Returns the geometry of action act. More... | |
QAction * | activeAction () const |
Returns the currently highlighted action, or 0 if no action is currently highlighted. More... | |
QAction * | addAction (const QString &text) |
This convenience function creates a new action with text. More... | |
QAction * | addAction (const QIcon &icon, const QString &text) |
This convenience function creates a new action with an icon and some text. More... | |
QAction * | addAction (const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut=0) |
This convenience function creates a new action with the text text and an optional shortcut shortcut. More... | |
QAction * | addAction (const QIcon &icon, const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut=0) |
This convenience function creates a new action with an icon and some text and an optional shortcut shortcut. More... | |
QAction * | addMenu (QMenu *menu) |
This convenience function adds menu as a submenu to this menu. More... | |
QMenu * | addMenu (const QString &title) |
Appends a new QMenu with title to the menu. More... | |
QMenu * | addMenu (const QIcon &icon, const QString &title) |
Appends a new QMenu with icon and title to the menu. More... | |
QAction * | addSeparator () |
This convenience function creates a new separator action, i.e. More... | |
void | clear () |
Removes all the menu's actions. More... | |
QAction * | defaultAction () const |
Returns the current default action. More... | |
QAction * | exec () |
Executes this menu synchronously. More... | |
QAction * | exec (const QPoint &pos, QAction *at=0) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Executes this menu synchronously. More... | |
void | hideTearOffMenu () |
This function will forcibly hide the torn off menu making it disappear from the users desktop. More... | |
QIcon | icon () const |
QAction * | insertMenu (QAction *before, QMenu *menu) |
This convenience function inserts menu before action before and returns the menus menuAction(). More... | |
QAction * | insertSeparator (QAction *before) |
This convenience function creates a new separator action, i.e. More... | |
bool | isEmpty () const |
Returns true if there are no visible actions inserted into the menu, false otherwise. More... | |
bool | isTearOffEnabled () const |
bool | isTearOffMenuVisible () const |
When a menu is torn off a second menu is shown to display the menu contents in a new window. More... | |
OSMenuRef | macMenu (OSMenuRef merge=0) |
QAction * | menuAction () const |
Returns the action associated with this menu. More... | |
void | popup (const QPoint &pos, QAction *at=0) |
Displays the menu so that the action atAction will be at the specified global position p. More... | |
QMenu (QWidget *parent=0) | |
Constructs a menu with parent parent. More... | |
QMenu (const QString &title, QWidget *parent=0) | |
Constructs a menu with a title and a parent. More... | |
bool | separatorsCollapsible () const |
void | setActiveAction (QAction *act) |
Sets the currently highlighted action to act. More... | |
void | setDefaultAction (QAction *) |
This sets the default action to act. More... | |
void | setIcon (const QIcon &icon) |
void | setNoReplayFor (QWidget *widget) |
void | setSeparatorsCollapsible (bool collapse) |
void | setTearOffEnabled (bool) |
void | setTitle (const QString &title) |
QSize | sizeHint () const |
Reimplemented Function More... | |
QString | title () const |
HMENU | wceMenu () |
This function will return the HMENU used to create the native Windows CE menu bar bindings. More... | |
~QMenu () | |
Destroys the menu. More... | |
Public Functions inherited from QWidget | |
bool | acceptDrops () const |
QString | accessibleDescription () const |
QString | accessibleName () const |
QList< QAction * > | actions () const |
Returns the (possibly empty) list of this widget's actions. More... | |
void | activateWindow () |
Sets the top-level widget containing this widget to be the active window. More... | |
void | addAction (QAction *action) |
Appends the action action to this widget's list of actions. More... | |
void | addActions (QList< QAction *> actions) |
Appends the actions actions to this widget's list of actions. More... | |
void | adjustSize () |
Adjusts the size of the widget to fit its contents. More... | |
bool | autoFillBackground () const |
QPalette::ColorRole | backgroundRole () const |
Returns the background role of the widget. More... | |
QSize | baseSize () const |
QWidget * | childAt (int x, int y) const |
Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system. More... | |
QWidget * | childAt (const QPoint &p) const |
Returns the visible child widget at point p in the widget's own coordinate system. More... | |
QRect | childrenRect () const |
QRegion | childrenRegion () const |
void | clearFocus () |
Takes keyboard input focus from the widget. More... | |
void | clearMask () |
Removes any mask set by setMask(). More... | |
QMargins | contentsMargins () const |
The contentsMargins function returns the widget's contents margins. More... | |
QRect | contentsRect () const |
Returns the area inside the widget's margins. More... | |
Qt::ContextMenuPolicy | contextMenuPolicy () const |
void | createWinId () |
QCursor | cursor () const |
int | devType () const |
WId | effectiveWinId () const |
Returns the effective window system identifier of the widget, i. More... | |
void | ensurePolished () const |
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette). More... | |
Qt::FocusPolicy | focusPolicy () const |
QWidget * | focusProxy () const |
Returns the focus proxy, or 0 if there is no focus proxy. More... | |
QWidget * | focusWidget () const |
Returns the last child of this widget that setFocus had been called on. More... | |
const QFont & | font () const |
QFontInfo | fontInfo () const |
Returns the font info for the widget's current font. More... | |
QFontMetrics | fontMetrics () const |
Returns the font metrics for the widget's current font. More... | |
QPalette::ColorRole | foregroundRole () const |
Returns the foreground role. More... | |
QRect | frameGeometry () const |
QSize | frameSize () const |
const QRect & | geometry () const |
void | getContentsMargins (int *left, int *top, int *right, int *bottom) const |
Returns the widget's contents margins for left, top, right, and bottom. More... | |
HDC | getDC () const |
Returns the window system handle of the widget, for low-level access. More... | |
void | grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags()) |
Subscribes the widget to a given gesture with specific flags. More... | |
void | grabKeyboard () |
Grabs the keyboard input. More... | |
void | grabMouse () |
Grabs the mouse input. More... | |
void | grabMouse (const QCursor &) |
int | grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut) |
Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. More... | |
QGraphicsEffect * | graphicsEffect () const |
The graphicsEffect function returns a pointer to the widget's graphics effect. More... | |
QGraphicsProxyWidget * | graphicsProxyWidget () const |
Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns 0. More... | |
bool | hasFocus () const |
bool | hasMouseTracking () const |
int | height () const |
virtual int | heightForWidth (int) const |
Returns the preferred height for this widget, given the width w. More... | |
QInputContext * | inputContext () |
This function returns the QInputContext for this widget. More... | |
Qt::InputMethodHints | inputMethodHints () const |
virtual QVariant | inputMethodQuery (Qt::InputMethodQuery) const |
This method is only relevant for input widgets. More... | |
void | insertAction (QAction *before, QAction *action) |
Inserts the action action to this widget's list of actions, before the action before. More... | |
void | insertActions (QAction *before, QList< QAction *> actions) |
Inserts the actions actions to this widget's list of actions, before the action before. More... | |
WId | internalWinId () const |
Returns the window system identifier of the widget, or 0 if the widget is not created yet. More... | |
bool | isActiveWindow () const |
bool | isAncestorOf (const QWidget *child) const |
Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child, and both widgets are within the same window; otherwise returns false. More... | |
bool | isEnabled () const |
bool | isEnabledTo (QWidget *) const |
Returns true if this widget would become enabled if ancestor is enabled; otherwise returns false. More... | |
bool | isEnabledToTLW () const |
This function is deprecated. More... | |
bool | isFullScreen () const |
bool | isHidden () const |
Returns true if the widget is hidden, otherwise returns false. More... | |
bool | isLeftToRight () const |
bool | isMaximized () const |
bool | isMinimized () const |
bool | isModal () const |
bool | isRightToLeft () const |
bool | isTopLevel () const |
Use isWindow() instead. More... | |
bool | isVisible () const |
bool | isVisibleTo (QWidget *) const |
Returns true if this widget would become visible if ancestor is shown; otherwise returns false. More... | |
bool | isWindow () const |
Returns true if the widget is an independent window, otherwise returns false. More... | |
bool | isWindowModified () const |
QLayout * | layout () const |
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed. More... | |
Qt::LayoutDirection | layoutDirection () const |
QLocale | locale () const |
Qt::HANDLE | macCGHandle () const |
Returns the CoreGraphics handle of the widget. More... | |
Qt::HANDLE | macQDHandle () const |
Returns the QuickDraw handle of the widget. More... | |
QPoint | mapFrom (QWidget *, const QPoint &) const |
Translates the widget coordinate pos from the coordinate system of parent to this widget's coordinate system. More... | |
QPoint | mapFromGlobal (const QPoint &) const |
Translates the global screen coordinate pos to widget coordinates. More... | |
QPoint | mapFromParent (const QPoint &) const |
Translates the parent widget coordinate pos to widget coordinates. More... | |
QPoint | mapTo (QWidget *, const QPoint &) const |
Translates the widget coordinate pos to the coordinate system of parent. More... | |
QPoint | mapToGlobal (const QPoint &) const |
Translates the widget coordinate pos to global screen coordinates. More... | |
QPoint | mapToParent (const QPoint &) const |
Translates the widget coordinate pos to a coordinate in the parent widget. More... | |
QRegion | mask () const |
Returns the mask currently set on a widget. More... | |
int | maximumHeight () const |
QSize | maximumSize () const |
int | maximumWidth () const |
int | minimumHeight () const |
QSize | minimumSize () const |
virtual QSize | minimumSizeHint () const |
int | minimumWidth () const |
void | move (int x, int y) |
This corresponds to move(QPoint(x, y)). More... | |
void | move (const QPoint &) |
QWidget * | nativeParentWidget () const |
Returns the native parent for this widget, i. More... | |
QWidget * | nextInFocusChain () const |
Returns the next widget in this widget's focus chain. More... | |
QRect | normalGeometry () const |
void | overrideWindowFlags (Qt::WindowFlags type) |
Sets the window flags for the widget to flags, without telling the window system. More... | |
void | overrideWindowState (Qt::WindowStates state) |
QPaintEngine * | paintEngine () const |
Returns the widget's paint engine. More... | |
const QPalette & | palette () const |
QWidget * | parentWidget () const |
Returns the parent of this widget, or 0 if it does not have any parent widget. More... | |
QPoint | pos () const |
QWidget * | previousInFocusChain () const |
The previousInFocusChain function returns the previous widget in this widget's focus chain. More... | |
QWidget (QWidget *parent=0, Qt::WindowFlags f=0) | |
Constructs a widget which is a child of parent, with widget flags set to f. More... | |
QRect | rect () const |
void | releaseDC (HDC) const |
Releases the HDC hdc acquired by a previous call to getDC(). More... | |
void | releaseKeyboard () |
Releases the keyboard grab. More... | |
void | releaseMouse () |
Releases the mouse grab. More... | |
void | releaseShortcut (int id) |
Removes the shortcut with the given id from Qt's shortcut system. More... | |
void | removeAction (QAction *action) |
Removes the action action from this widget's list of actions. More... | |
void | render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren)) |
Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. More... | |
void | render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren)) |
Renders the widget into the painter's QPainter::device(). More... | |
void | repaint (int x, int y, int w, int h) |
This version repaints a rectangle (x, y, w, h) inside the widget. More... | |
void | repaint (const QRect &) |
This version repaints a rectangle rect inside the widget. More... | |
void | repaint (const QRegion &) |
This version repaints a region rgn inside the widget. More... | |
void | resize (int w, int h) |
This corresponds to resize(QSize(w, h)). More... | |
void | resize (const QSize &) |
bool | restoreGeometry (const QByteArray &geometry) |
Restores the geometry and state top-level widgets stored in the byte array geometry. More... | |
QByteArray | saveGeometry () const |
Saves the current geometry and state for top-level widgets. More... | |
void | scroll (int dx, int dy) |
Scrolls the widget including its children dx pixels to the right and dy downward. More... | |
void | scroll (int dx, int dy, const QRect &) |
This version only scrolls r and does not move the children of the widget. More... | |
void | setAcceptDrops (bool on) |
void | setAccessibleDescription (const QString &description) |
void | setAccessibleName (const QString &name) |
void | setAttribute (Qt::WidgetAttribute, bool on=true) |
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute. More... | |
void | setAutoFillBackground (bool enabled) |
void | setBackgroundRole (QPalette::ColorRole) |
Sets the background role of the widget to role. More... | |
void | setBaseSize (const QSize &) |
void | setBaseSize (int basew, int baseh) |
This corresponds to setBaseSize(QSize(basew, baseh)). More... | |
void | setContentsMargins (int left, int top, int right, int bottom) |
Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom. More... | |
void | setContentsMargins (const QMargins &margins) |
The setContentsMargins function sets the margins around the widget's contents. More... | |
void | setContextMenuPolicy (Qt::ContextMenuPolicy policy) |
void | setCursor (const QCursor &) |
void | setFixedHeight (int h) |
Sets both the minimum and maximum heights of the widget to h without changing the widths. More... | |
void | setFixedSize (const QSize &) |
Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking. More... | |
void | setFixedSize (int w, int h) |
Sets the width of the widget to w and the height to h. More... | |
void | setFixedWidth (int w) |
Sets both the minimum and maximum width of the widget to w without changing the heights. More... | |
void | setFocus (Qt::FocusReason reason) |
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More... | |
void | setFocusPolicy (Qt::FocusPolicy policy) |
void | setFocusProxy (QWidget *) |
Sets the widget's focus proxy to widget w. More... | |
void | setFont (const QFont &) |
Use the single-argument overload instead. More... | |
void | setForegroundRole (QPalette::ColorRole) |
Sets the foreground role of the widget to role. More... | |
void | setGeometry (int x, int y, int w, int h) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This corresponds to setGeometry(QRect(x, y, w, h)). More... | |
void | setGeometry (const QRect &) |
void | setGraphicsEffect (QGraphicsEffect *effect) |
The setGraphicsEffect function is for setting the widget's graphics effect. More... | |
void | setInputContext (QInputContext *) |
This function sets the input context context on this widget. More... | |
void | setInputMethodHints (Qt::InputMethodHints hints) |
void | setLayout (QLayout *) |
Sets the layout manager for this widget to layout. More... | |
void | setLayoutDirection (Qt::LayoutDirection direction) |
void | setLocale (const QLocale &locale) |
void | setMask (const QBitmap &) |
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. More... | |
void | setMask (const QRegion &) |
Causes only the parts of the widget which overlap region to be visible. More... | |
void | setMaximumHeight (int maxh) |
void | setMaximumSize (const QSize &) |
void | setMaximumSize (int maxw, int maxh) |
This function corresponds to setMaximumSize(QSize(maxw, maxh)). More... | |
void | setMaximumWidth (int maxw) |
void | setMinimumHeight (int minh) |
void | setMinimumSize (const QSize &) |
void | setMinimumSize (int minw, int minh) |
This function corresponds to setMinimumSize(QSize(minw, minh)). More... | |
void | setMinimumWidth (int minw) |
void | setMouseTracking (bool enable) |
void | setPalette (const QPalette &) |
Use the single-argument overload instead. More... | |
void | setParent (QWidget *parent) |
Sets the parent of the widget to parent, and resets the window flags. More... | |
void | setParent (QWidget *parent, Qt::WindowFlags f) |
This function also takes widget flags, f as an argument. More... | |
void | setShortcutAutoRepeat (int id, bool enable=true) |
If enable is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled. More... | |
void | setShortcutEnabled (int id, bool enable=true) |
If enable is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled. More... | |
void | setSizeIncrement (const QSize &) |
void | setSizeIncrement (int w, int h) |
Sets the x (width) size increment to w and the y (height) size increment to h. More... | |
void | setSizePolicy (QSizePolicy) |
void | setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical) |
Sets the size policy of the widget to horizontal and vertical, with standard stretch and no height-for-width. More... | |
void | setStatusTip (const QString &) |
void | setStyle (QStyle *) |
Sets the widget's GUI style to style. More... | |
void | setToolTip (const QString &) |
void | setUpdatesEnabled (bool enable) |
void | setupUi (QWidget *widget) |
Sets up the user interface for the specified widget. More... | |
void | setWhatsThis (const QString &) |
void | setWindowFilePath (const QString &filePath) |
void | setWindowFlags (Qt::WindowFlags type) |
void | setWindowIcon (const QIcon &icon) |
void | setWindowIconText (const QString &) |
void | setWindowModality (Qt::WindowModality windowModality) |
void | setWindowOpacity (qreal level) |
void | setWindowRole (const QString &) |
Sets the window's role to role. More... | |
void | setWindowState (Qt::WindowStates state) |
Sets the window state to windowState. More... | |
void | setWindowSurface (QWindowSurface *surface) |
Sets the window surface to be the surface specified. More... | |
QSize | size () const |
QSize | sizeIncrement () const |
QSizePolicy | sizePolicy () const |
void | stackUnder (QWidget *) |
Places the widget under w in the parent widget's stack. More... | |
QString | statusTip () const |
QStyle * | style () const |
QString | styleSheet () const |
bool | testAttribute (Qt::WidgetAttribute) const |
Returns true if attribute attribute is set on this widget; otherwise returns false. More... | |
QString | toolTip () const |
QWidget * | topLevelWidget () const |
bool | underMouse () const |
Returns true if the widget is under the mouse cursor; otherwise returns false. More... | |
void | ungrabGesture (Qt::GestureType type) |
Unsubscribes the widget from a given gesture type. More... | |
void | unsetCursor () |
void | unsetLayoutDirection () |
void | unsetLocale () |
void | update (int x, int y, int w, int h) |
This version updates a rectangle (x, y, w, h) inside the widget. More... | |
void | update (const QRect &) |
This version updates a rectangle rect inside the widget. More... | |
void | update (const QRegion &) |
This version repaints a region rgn inside the widget. More... | |
void | updateGeometry () |
Notifies the layout system that this widget has changed and may need to change geometry. More... | |
bool | updatesEnabled () const |
QRegion | visibleRegion () const |
Returns the unobscured region where paint events can occur. More... | |
QString | whatsThis () const |
int | width () const |
QWidget * | window () const |
Returns the window for this widget, i.e. More... | |
QString | windowFilePath () const |
Qt::WindowFlags | windowFlags () const |
Window flags are a combination of a type (e. More... | |
QIcon | windowIcon () const |
QString | windowIconText () const |
Qt::WindowModality | windowModality () const |
qreal | windowOpacity () const |
QString | windowRole () const |
Returns the window's role, or an empty string. More... | |
Qt::WindowStates | windowState () const |
Returns the current window state. More... | |
QWindowSurface * | windowSurface () const |
Returns the QWindowSurface this widget will be drawn into. More... | |
QString | windowTitle () const |
Qt::WindowType | windowType () const |
Returns the window type of this widget. More... | |
WId | winId () const |
Returns the window system identifier of the widget. More... | |
int | x () const |
const QX11Info & | x11Info () const |
Returns information about the configuration of the X display used to display the widget. More... | |
Qt::HANDLE | x11PictureHandle () const |
Returns the X11 Picture handle of the widget for XRender support. More... | |
int | y () const |
~QWidget () | |
Destroys the widget. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Public Functions inherited from QPaintDevice | |
int | colorCount () const |
int | depth () const |
int | height () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
QT_DEPRECATED int | numColors () const |
bool | paintingActive () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
int | width () const |
int | widthMM () const |
virtual | ~QPaintDevice () |
Static Public Functions | |
static QAction * | exec (QList< QAction *> actions, const QPoint &pos, QAction *at=0) |
Executes a menu synchronously. More... | |
static QAction * | exec (QList< QAction *> actions, const QPoint &pos, QAction *at, QWidget *parent) |
Executes a menu synchronously. More... | |
Static Public Functions inherited from QWidget | |
static QWidget * | find (WId) |
Returns a pointer to the widget with window identifer/handle id. More... | |
static QWidget * | keyboardGrabber () |
Returns the widget that is currently grabbing the keyboard input. More... | |
static QWidget * | mouseGrabber () |
Returns the widget that is currently grabbing the mouse input. More... | |
static void | setTabOrder (QWidget *, QWidget *) |
Puts the second widget after the first widget in the focus order. More... | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Functions inherited from QPaintDevice | |
static QWSDisplay * | qwsDisplay () |
Protected Functions | |
void | actionEvent (QActionEvent *) |
Reimplemented Function More... | |
void | changeEvent (QEvent *) |
Reimplemented Function More... | |
int | columnCount () const |
If a menu does not fit on the screen it lays itself out so that it does fit. More... | |
void | enterEvent (QEvent *) |
Reimplemented Function More... | |
bool | event (QEvent *) |
Reimplemented Function More... | |
bool | focusNextPrevChild (bool next) |
Reimplemented Function More... | |
void | hideEvent (QHideEvent *) |
Reimplemented Function More... | |
void | initStyleOption (QStyleOptionMenuItem *option, const QAction *action) const |
Initialize option with the values from this menu and information from action. More... | |
void | keyPressEvent (QKeyEvent *) |
Reimplemented Function More... | |
void | leaveEvent (QEvent *) |
Reimplemented Function More... | |
void | mouseMoveEvent (QMouseEvent *) |
Reimplemented Function More... | |
void | mousePressEvent (QMouseEvent *) |
Reimplemented Function More... | |
void | mouseReleaseEvent (QMouseEvent *) |
Reimplemented Function More... | |
void | paintEvent (QPaintEvent *) |
Reimplemented Function More... | |
QMenu (QMenuPrivate &dd, QWidget *parent=0) | |
void | timerEvent (QTimerEvent *) |
Reimplemented Function More... | |
QAction * | wceCommands (uint command) |
This function sends native Windows CE commands to Qt menus. More... | |
void | wheelEvent (QWheelEvent *) |
Reimplemented Function More... | |
Protected Functions inherited from QWidget | |
virtual void | closeEvent (QCloseEvent *) |
This event handler is called with the given event when Qt receives a window close request for a top-level widget from the window system. More... | |
virtual void | contextMenuEvent (QContextMenuEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive widget context menu events. More... | |
void | create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true) |
Creates a new widget window if window is 0, otherwise sets the widget's window to window. More... | |
void | destroy (bool destroyWindow=true, bool destroySubWindows=true) |
Frees up window system resources. More... | |
virtual void | dragEnterEvent (QDragEnterEvent *) |
This event handler is called when a drag is in progress and the mouse enters this widget. More... | |
virtual void | dragLeaveEvent (QDragLeaveEvent *) |
This event handler is called when a drag is in progress and the mouse leaves this widget. More... | |
virtual void | dragMoveEvent (QDragMoveEvent *) |
This event handler is called if a drag is in progress, and when any of the following conditions occur: the cursor enters this widget, the cursor moves within this widget, or a modifier key is pressed on the keyboard while this widget has the focus. More... | |
virtual void | dropEvent (QDropEvent *) |
This event handler is called when the drag is dropped on this widget. More... | |
virtual void | enabledChange (bool) |
virtual void | focusInEvent (QFocusEvent *) |
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. More... | |
bool | focusNextChild () |
Finds a new widget to give the keyboard focus to, as appropriate for Tab, and returns true if it can find a new widget, or false if it can't. More... | |
virtual void | focusOutEvent (QFocusEvent *) |
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget. More... | |
bool | focusPreviousChild () |
Finds a new widget to give the keyboard focus to, as appropriate for Shift+Tab, and returns true if it can find a new widget, or false if it can't. More... | |
virtual void | fontChange (const QFont &) |
virtual void | inputMethodEvent (QInputMethodEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive Input Method composition events. More... | |
virtual void | keyReleaseEvent (QKeyEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive key release events for the widget. More... | |
virtual void | languageChange () |
virtual bool | macEvent (EventHandlerCallRef, EventRef) |
This special event handler can be reimplemented in a subclass to receive native Macintosh events. More... | |
int | metric (PaintDeviceMetric) const |
Internal implementation of the virtual QPaintDevice::metric() function. More... | |
virtual void | mouseDoubleClickEvent (QMouseEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive mouse double click events for the widget. More... | |
virtual void | moveEvent (QMoveEvent *) |
This event handler can be reimplemented in a subclass to receive widget move events which are passed in the event parameter. More... | |
virtual void | paletteChange (const QPalette &) |
QWidget (QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f) | |
virtual bool | qwsEvent (QWSEvent *) |
This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux events which are passed in the event parameter. More... | |
void | resetInputContext () |
This function can be called on the widget that currently has focus to reset the input method operating on it. More... | |
virtual void | resizeEvent (QResizeEvent *) |
This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the event parameter. More... | |
virtual void | showEvent (QShowEvent *) |
This event handler can be reimplemented in a subclass to receive widget show events which are passed in the event parameter. More... | |
virtual void | styleChange (QStyle &) |
virtual void | tabletEvent (QTabletEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive tablet events for the widget. More... | |
virtual void | windowActivationChange (bool) |
virtual bool | winEvent (MSG *message, long *result) |
This special event handler can be reimplemented in a subclass to receive native Windows events which are passed in the message parameter. More... | |
virtual bool | x11Event (XEvent *) |
This special event handler can be reimplemented in a subclass to receive native X11 events passed in the event parameter. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
Protected Functions inherited from QPaintDevice | |
QPaintDevice () | |
Private Slots | |
void | internalDelayedPopup () |
void | internalSetSloppyAction () |
Properties | |
QIcon | icon |
The icon of the menu. More... | |
bool | separatorsCollapsible |
whether consecutive separators should be collapsed More... | |
bool | tearOffEnabled |
whether the menu supports being torn off More... | |
QString | title |
The title of the menu. More... | |
Friends | |
class | Q3PopupMenu |
class | QAction |
class | QComboBox |
class | QMenuBar |
class | QMenuBarPrivate |
bool | qt_mac_activate_action (OSMenuRef, uint, QAction::ActionEvent, bool) |
void | qt_mac_emit_menuSignals (QMenu *, bool) |
void | qt_mac_menu_emit_hovered (QMenu *menu, QAction *action) |
OSStatus | qt_mac_menu_event (EventHandlerCallRef, EventRef, void *) |
void | qt_mac_trayicon_activate_action (QMenu *, QAction *action) |
bool | qt_mac_watchingAboutToShow (QMenu *) |
class | QToolButtonPrivate |
class | QTornOffMenu |
Additional Inherited Members | |
Public Types inherited from QWidget | |
enum | RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 } |
This enum describes how to render the widget when calling QWidget::render(). More... | |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric { PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM, PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY, PdmPhysicalDpiX, PdmPhysicalDpiY } |
Public Slots inherited from QWidget | |
bool | close () |
Closes this widget. More... | |
void | hide () |
Hides the widget. More... | |
void | lower () |
Lowers the widget to the bottom of the parent widget's stack. More... | |
void | raise () |
Raises this widget to the top of the parent widget's stack. More... | |
void | repaint () |
Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. More... | |
void | setDisabled (bool) |
Disables widget input events if disable is true; otherwise enables input events. More... | |
void | setEnabled (bool) |
void | setFocus () |
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More... | |
void | setHidden (bool hidden) |
Convenience function, equivalent to setVisible(!hidden). More... | |
QT_MOC_COMPAT void | setShown (bool shown) |
Use setVisible(shown) instead. More... | |
void | setStyleSheet (const QString &styleSheet) |
virtual void | setVisible (bool visible) |
void | setWindowModified (bool) |
void | setWindowTitle (const QString &) |
void | show () |
Shows the widget and its child widgets. More... | |
void | showFullScreen () |
Shows the widget in full-screen mode. More... | |
void | showMaximized () |
Shows the widget maximized. More... | |
void | showMinimized () |
Shows the widget minimized, as an icon. More... | |
void | showNormal () |
Restores the widget after it has been maximized or minimized. More... | |
void | update () |
Updates the widget unless updates are disabled or the widget is hidden. More... | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Slots inherited from QWidget | |
void | updateMicroFocus () |
Updates the widget's micro focus. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Protected Variables inherited from QPaintDevice | |
ushort | painters |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QWidget | |
QWidgetList | |
WId | |
Platform dependent window identifier. More... | |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
Related Functions inherited from QPaintDevice | |
const Q_GUI_EXPORT QX11Info * | qt_x11Info (const QPaintDevice *pd) |
Returns the QX11Info structure for the pd paint device. More... | |
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
A menu widget is a selection menu. It can be either a pull-down menu in a menu bar or a standalone context menu. Pull-down menus are shown by the menu bar when the user clicks on the respective item or presses the specified shortcut key. Use QMenuBar::addMenu() to insert a menu into a menu bar. Context menus are usually invoked by some special keyboard key or by right-clicking. They can be executed either asynchronously with popup() or synchronously with exec(). Menus can also be invoked in response to button presses; these are just like context menus except for how they are invoked.
Fig. A menu shown in Plastique Style Widget Gallery{Plastique widget style}, Windows XP Style Widget Gallery{Windows XP widget style}, and Macintosh Style Widget Gallery{Macintosh widget style}.
A menu consists of a list of action items. Actions are added with the addAction(), addActions() and insertAction() functions. An action is represented vertically and rendered by QStyle. In addition, actions can have a text label, an optional icon drawn on the very left side, and shortcut key sequence such as "Ctrl+X".
The existing actions held by a menu can be found with actions().
There are four kinds of action items: separators, actions that show a submenu, widgets, and actions that perform an action. Separators are inserted with addSeparator(), submenus with addMenu(), and all other items are considered action items.
When inserting action items you usually specify a receiver and a slot. The receiver will be notifed whenever the item is triggered(). In addition, QMenu provides two signals, activated() and highlighted(), which signal the QAction that was triggered from the menu.
You clear a menu with clear() and remove individual action items with removeAction().
A QMenu can also provide a tear-off menu. A tear-off menu is a top-level window that contains a copy of the menu. This makes it possible for the user to "tear off" frequently used menus and position them in a convenient place on the screen. If you want this functionality for a particular menu, insert a tear-off handle with setTearOffEnabled(). When using tear-off menus, bear in mind that the concept isn't typically used on Microsoft Windows so some users may not be familiar with it. Consider using a QToolBar instead.
Widgets can be inserted into menus with the QWidgetAction class. Instances of this class are used to hold widgets, and are inserted into menus with the addAction() overload that takes a QAction.
Conversely, actions can be added to widgets with the addAction(), addActions() and insertAction() functions.
If a menu is integrated into the native menubar on Windows Mobile we do not support the signals: aboutToHide (), aboutToShow () and hovered (). It is not possible to display an icon in a native menu on Windows Mobile.
QMenu can be inserted only once in a menu/menubar. Subsequent insertions will have no effect or will result in a disabled menu item.
See the Menus example for an example of how to use QMenuBar and QMenu in your application.
Important inherited functions: addAction(), removeAction(), clear(), addSeparator(), and addMenu().
|
explicit |
Constructs a menu with parent parent.
Although a popup menu is always a top-level widget, if a parent is passed the popup menu will be deleted when that parent is destroyed (as with any other QObject).
Definition at line 1386 of file qmenu.cpp.
Referenced by addMenu().
Constructs a menu with a title and a parent.
Although a popup menu is always a top-level widget, if a parent is passed the popup menu will be deleted when that parent is destroyed (as with any other QObject).
Definition at line 1402 of file qmenu.cpp.
QMenu::~QMenu | ( | ) |
Destroys the menu.
Definition at line 1422 of file qmenu.cpp.
|
protected |
Definition at line 1412 of file qmenu.cpp.
|
signal |
This signal is emitted just before the menu is hidden from the user.
Referenced by hideEvent().
|
signal |
This signal is emitted just before the menu is shown to the user.
Referenced by popup().
Returns the item at pt; returns 0 if there is no item there.
Definition at line 1787 of file qmenu.cpp.
Referenced by QAccessibleMenu::childAt().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2969 of file qmenu.cpp.
Referenced by QTornOffMenu::actionEvent().
Returns the geometry of action act.
Definition at line 1797 of file qmenu.cpp.
Referenced by QAccessibleMenu::rect().
QAction * QMenu::activeAction | ( | ) | const |
Returns the currently highlighted action, or 0 if no action is currently highlighted.
Definition at line 1720 of file qmenu.cpp.
Referenced by QMenuPrivate::hideMenu(), and QAccessibleMenu::state().
This convenience function creates a new action with text.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The function adds the newly created action to the menu's list of actions, and returns it.
Definition at line 1453 of file qmenu.cpp.
Referenced by QFileDialogPrivate::_q_showContextMenu(), addAction(), addMenu(), addSeparator(), QMdiSubWindowPrivate::addToSystemMenu(), QDecoration::buildSysMenu(), QmlJSDebugger::ToolBarColorBox::contextMenuEvent(), QScrollBar::contextMenuEvent(), QDialog::contextMenuEvent(), QAbstractSpinBox::contextMenuEvent(), QmlJSDebugger::LiveSelectionTool::createContextMenu(), QCalendarWidgetPrivate::createNavigationBar(), QMainWindow::createPopupMenu(), QTextControl::createStandardContextMenu(), QLineEdit::createStandardContextMenu(), QScriptDebugger::createStandardMenu(), QScriptEdit::extraAreaMouseEvent(), QToolBarLayout::layoutActions(), menuItemEntry(), QmlJSDebugger::ZoomTool::mousePressEvent(), QToolButtonPrivate::popupTimerDone(), QmlJSDebugger::QmlToolBar::QmlToolBar(), QMultiInputContext::QMultiInputContext(), QTornOffMenu::QTornOffMenu(), QUnicodeControlCharacterMenu::QUnicodeControlCharacterMenu(), setSeparatorsCollapsible(), and QScriptEngineDebugger::standardWindow().
This convenience function creates a new action with an icon and some text.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The function adds the newly created action to the menu's list of actions, and returns it.
Definition at line 1472 of file qmenu.cpp.
QAction * QMenu::addAction | ( | const QString & | text, |
const QObject * | receiver, | ||
const char * | member, | ||
const QKeySequence & | shortcut = 0 |
||
) |
This convenience function creates a new action with the text text and an optional shortcut shortcut.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
Definition at line 1493 of file qmenu.cpp.
QAction * QMenu::addAction | ( | const QIcon & | icon, |
const QString & | text, | ||
const QObject * | receiver, | ||
const char * | member, | ||
const QKeySequence & | shortcut = 0 |
||
) |
This convenience function creates a new action with an icon and some text and an optional shortcut shortcut.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The action's triggered() signal is connected to the member slot of the receiver object. The function adds the newly created action to the menu's list of actions, and returns it.
Definition at line 1520 of file qmenu.cpp.
This convenience function adds menu as a submenu to this menu.
It returns menu's menuAction(). This menu does not take ownership of menu.
Definition at line 1541 of file qmenu.cpp.
Referenced by QTextControl::createStandardContextMenu(), QLineEdit::createStandardContextMenu(), and menuItemEntry().
Appends a new QMenu with title to the menu.
The menu takes ownership of the menu. Returns the new menu.
Definition at line 1554 of file qmenu.cpp.
Appends a new QMenu with icon and title to the menu.
The menu takes ownership of the menu. Returns the new menu.
Definition at line 1567 of file qmenu.cpp.
QAction * QMenu::addSeparator | ( | ) |
This convenience function creates a new separator action, i.e.
an action with QAction::isSeparator() returning true, and adds the new action to this menu's list of actions. It returns the newly created action.
Definition at line 1583 of file qmenu.cpp.
Referenced by QFileDialogPrivate::_q_showContextMenu(), QDecoration::buildSysMenu(), QScrollBar::contextMenuEvent(), QAbstractSpinBox::contextMenuEvent(), QmlJSDebugger::LiveSelectionTool::createContextMenu(), QMainWindow::createPopupMenu(), QTextControl::createStandardContextMenu(), QLineEdit::createStandardContextMenu(), QScriptDebugger::createStandardMenu(), QMdiSubWindowPrivate::createSystemMenu(), QScriptEdit::extraAreaMouseEvent(), menuItemEntry(), QmlJSDebugger::ZoomTool::mousePressEvent(), and QScriptEngineDebugger::standardWindow().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2414 of file qmenu.cpp.
void QMenu::clear | ( | ) |
Removes all the menu's actions.
Actions owned by the menu and not shown in any other widget are deleted.
Definition at line 1755 of file qmenu.cpp.
Referenced by QToolBarLayout::layoutActions(), and QMenuBarPrivate::updateGeometries().
|
protected |
If a menu does not fit on the screen it lays itself out so that it does fit.
It is style dependent what layout means (for example, on Windows it will use multiple columns).
This functions returns the number of columns necessary.
QAction * QMenu::defaultAction | ( | ) | const |
Returns the current default action.
|
protectedvirtual |
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2447 of file qmenu.cpp.
QAction * QMenu::exec | ( | ) |
Executes this menu synchronously.
This is equivalent to exec(pos())
.
This returns the triggered QAction in either the popup menu or one of its submenus, or 0 if no item was triggered (normally because the user pressed Esc).
In most situations you'll want to specify the position yourself, for example, the current mouse position:
or aligned to a widget:
or in reaction to a QMouseEvent *e:
Definition at line 2101 of file qmenu.cpp.
Referenced by QPushButtonPrivate::_q_popupPressed(), QFileDialogPrivate::_q_showContextMenu(), QmlJSDebugger::ToolBarColorBox::contextMenuEvent(), QScrollBar::contextMenuEvent(), QDialog::contextMenuEvent(), QAbstractSpinBox::contextMenuEvent(), QMdiAreaTabBar::contextMenuEvent(), QmlJSDebugger::LiveSelectionTool::createContextMenu(), QWidget::event(), exec(), QScriptEdit::extraAreaMouseEvent(), QmlJSDebugger::ZoomTool::mousePressEvent(), QToolButtonPrivate::popupTimerDone(), and QSidebar::showContextMenu().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Executes this menu synchronously.
Pops up the menu so that the action action will be at the specified global position p. To translate a widget's local coordinates into global coordinates, use QWidget::mapToGlobal().
This returns the triggered QAction in either the popup menu or one of its submenus, or 0 if no item was triggered (normally because the user pressed Esc).
Note that all signals are emitted as usual. If you connect a QAction to a slot and call the menu's exec(), you get the result both via the signal-slot connection and in the return value of exec().
Common usage is to position the menu at the current mouse position:
or aligned to a widget:
or in reaction to a QMouseEvent *e:
When positioning a menu with exec() or popup(), bear in mind that you cannot rely on the menu's current size(). For performance reasons, the menu adapts its size only when necessary. So in many cases, the size before and after the show is different. Instead, use sizeHint() which calculates the proper size depending on the menu's current contents.
Definition at line 2142 of file qmenu.cpp.
Executes a menu synchronously.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The menu's actions are specified by the list of actions. The menu will pop up so that the specified action, at, appears at global position pos. If at is not specified then the menu appears at position pos.
The function returns the triggered QAction in either the popup menu or one of its submenus, or 0 if no item was triggered (normally because the user pressed Esc).
This is equivalent to:
Definition at line 2215 of file qmenu.cpp.
|
static |
Executes a menu synchronously.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The menu's actions are specified by the list of actions. The menu will pop up so that the specified action, at, appears at global position pos. If at is not specified then the menu appears at position pos. parent is the menu's parent widget; specifying the parent will provide context when pos alone is not enough to decide where the menu should go (e.g., with multiple desktops or when the parent is embedded in QGraphicsView).
The function returns the triggered QAction in either the popup menu or one of its submenus, or 0 if no item was triggered (normally because the user pressed Esc).
This is equivalent to:
Definition at line 2186 of file qmenu.cpp.
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2519 of file qmenu.cpp.
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2224 of file qmenu.cpp.
void QMenu::hideTearOffMenu | ( | ) |
This function will forcibly hide the torn off menu making it disappear from the users desktop.
Definition at line 1697 of file qmenu.cpp.
Referenced by setTearOffEnabled(), and ~QMenu().
|
signal |
This signal is emitted when a menu action is highlighted; action is the action that caused the signal to be emitted.
Often this is used to update status information.
Referenced by actionEvent().
QIcon QMenu::icon | ( | ) | const |
Referenced by setSeparatorsCollapsible(), and setTitle().
|
protected |
Initialize option with the values from this menu and information from action.
This method is useful for subclasses when they need a QStyleOptionMenuItem, but don't want to fill in all the information themselves.
Definition at line 1222 of file qmenu.cpp.
Referenced by paintEvent().
This convenience function inserts menu before action before and returns the menus menuAction().
Definition at line 1597 of file qmenu.cpp.
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 menu's list of actions before action before and returns it.
Definition at line 1612 of file qmenu.cpp.
Referenced by setSeparatorsCollapsible().
|
privateslot |
Definition at line 3048 of file qmenu.cpp.
Referenced by event(), and timerEvent().
|
privateslot |
Definition at line 3039 of file qmenu.cpp.
Referenced by timerEvent().
bool QMenu::isEmpty | ( | ) | const |
Returns true if there are no visible actions inserted into the menu, false otherwise.
Definition at line 1737 of file qmenu.cpp.
Referenced by QMainWindow::contextMenuEvent(), and QLineEdit::createStandardContextMenu().
bool QMenu::isTearOffEnabled | ( | ) | const |
bool QMenu::isTearOffMenuVisible | ( | ) | const |
When a menu is torn off a second menu is shown to display the menu contents in a new window.
When the menu is in this mode and the menu is visible returns true; otherwise false.
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2530 of file qmenu.cpp.
Referenced by event(), and focusNextPrevChild().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2933 of file qmenu.cpp.
This function will return the OSMenuRef used to create the native menu bar bindings.
If Qt is built against Carbon, the OSMenuRef is a MenuRef that can be used with Carbon's Menu Manager API.
If Qt is built against Cocoa, the OSMenuRef is a NSMenu pointer.
Definition at line 1610 of file qmenu_mac.mm.
Referenced by actualMenuItemVisibility(), qt_mac_set_dock_menu(), QMenuBarPrivate::QMacMenuBarPrivate::syncAction(), and QMenuPrivate::QMacMenuPrivate::syncAction().
QAction * QMenu::menuAction | ( | ) | const |
Returns the action associated with this menu.
Definition at line 711 of file qmenu.cpp.
Referenced by QMultiInputContext::actions(), QMenuBar::addMenu(), addMenu(), QMenuBar::defaultAction(), QMenuBar::insertMenu(), insertMenu(), QToolButton::setMenu(), setSeparatorsCollapsible(), and waitForPopup().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2887 of file qmenu.cpp.
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2360 of file qmenu.cpp.
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2384 of file qmenu.cpp.
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2249 of file qmenu.cpp.
Displays the menu so that the action atAction will be at the specified global position p.
Use popup() on the relevant QAction instead.
To translate a widget's local coordinates into global coordinates, use QWidget::mapToGlobal().
When positioning a menu with exec() or popup(), bear in mind that you cannot rely on the menu's current size(). For performance reasons, the menu adapts its size only when necessary, so in many cases, the size before and after the show is different. Instead, use sizeHint() which calculates the proper size depending on the menu's current contents.
Definition at line 1847 of file qmenu.cpp.
Referenced by QMessageBoxDetailsText::TextEdit::contextMenuEvent(), QLabel::contextMenuEvent(), QTextControlPrivate::contextMenuEvent(), QMainWindow::contextMenuEvent(), exec(), QSystemTrayIconSys::mousePressEvent(), setSeparatorsCollapsible(), and QSystemTrayIconSys::winEvent().
bool QMenu::separatorsCollapsible | ( | ) | const |
Referenced by setNoReplayFor().
void QMenu::setActiveAction | ( | QAction * | act | ) |
Sets the currently highlighted action to act.
Definition at line 1707 of file qmenu.cpp.
Referenced by QAccessibleMenu::doAction(), QMenuPrivate::hideMenu(), and leaveEvent().
void QMenu::setDefaultAction | ( | QAction * | act | ) |
This sets the default action to act.
The default action may have a visual cue, depending on the current QStyle. A default action usually indicates what will happen by default when a drop occurs.
void QMenu::setIcon | ( | const QIcon & | icon | ) |
Definition at line 754 of file qmenu.cpp.
Referenced by QMenuBar::addMenu(), and addMenu().
void QMenu::setNoReplayFor | ( | QWidget * | noReplayFor | ) |
Definition at line 3164 of file qmenu.cpp.
Referenced by QPushButtonPrivate::_q_popupPressed(), and QToolButtonPrivate::popupTimerDone().
void QMenu::setSeparatorsCollapsible | ( | bool | collapse | ) |
Definition at line 3194 of file qmenu.cpp.
void QMenu::setTearOffEnabled | ( | bool | b | ) |
Definition at line 1658 of file qmenu.cpp.
void QMenu::setTitle | ( | const QString & | title | ) |
Definition at line 732 of file qmenu.cpp.
Referenced by QScriptDebugger::createStandardMenu(), menuItemEntry(), and QUnicodeControlCharacterMenu::QUnicodeControlCharacterMenu().
|
virtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 1805 of file qmenu.cpp.
Referenced by QWorkspacePrivate::_q_showOperationMenu(), QTornOffMenu::actionEvent(), actionEvent(), QPushButtonPrivate::adjustedMenuPosition(), changeEvent(), popup(), QToolButtonPrivate::popupTimerDone(), and setTearOffEnabled().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QObject.
Definition at line 2947 of file qmenu.cpp.
QString QMenu::title | ( | ) | const |
Referenced by menuAction().
|
signal |
This signal is emitted when an action in this menu is triggered.
action is the action that caused the signal to be emitted.
Normally, you connect each menu action's QAction::triggered() signal to its own custom slot, but sometimes you will want to connect several actions to a single slot, for example, when you have a group of closely related actions, such as "left justify", "center", "right justify".
Referenced by actionEvent(), and addAction().
This function sends native Windows CE commands to Qt menus.
Definition at line 297 of file qmenu_wince.cpp.
Referenced by QMenuPrivate::wceCommands(), and QMenuBarPrivate::wceEmitSignals().
HMENU QMenu::wceMenu | ( | ) |
This function will return the HMENU used to create the native Windows CE menu bar bindings.
Definition at line 478 of file qmenu_wince.cpp.
Referenced by qt_wce_insert_action().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 2348 of file qmenu.cpp.
Definition at line 415 of file qmenu.h.
Referenced by addAction(), addSeparator(), QMenuPrivate::init(), insertSeparator(), and setSeparatorsCollapsible().
|
friend |
|
friend |
Definition at line 209 of file qmenu_mac.mm.
|
friend |
|
friend |
Definition at line 397 of file qmenu_mac.mm.
|
friend |
Definition at line 119 of file qmenu_mac.mm.
|
friend |
|
friend |
|
private |
The icon of the menu.
This is equivalent to the QAction::icon property of the menuAction().
By default, if no icon is explicitly set, this property contains a null icon.
|
private |
whether consecutive separators should be collapsed
This property specifies whether consecutive separators in the menu should be visually collapsed to a single one. Separators at the beginning or the end of the menu are also hidden.
By default, this property is true.
|
private |
whether the menu supports being torn off
When true, the menu contains a special tear-off item (often shown as a dashed line at the top of the menu) that creates a copy of the menu when it is triggered.
This "torn-off" copy lives in a separate window. It contains the same menu items as the original menu, with the exception of the tear-off handle.
By default, this property is false.
|
private |
The title of the menu.
This is equivalent to the QAction::text property of the menuAction().
By default, this property contains an empty string.
Definition at line 79 of file qmenu.h.
Referenced by QAccessibleMenuItem::text().