QtBase  v6.3.1
Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | Friends | List of all members
QMenu Class Reference

The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus. More...

#include <qmenu.h>

Inheritance diagram for QMenu:
Inheritance graph
[legend]
Collaboration diagram for QMenu:
Collaboration graph
[legend]

Signals

void aboutToShow ()
 
void aboutToHide ()
 
void triggered (QAction *action)
 
void hovered (QAction *action)
 
- Signals inherited from QWidget
void windowTitleChanged (const QString &title)
 
void windowIconChanged (const QIcon &icon)
 
void windowIconTextChanged (const QString &iconText)
 
void customContextMenuRequested (const QPoint &pos)
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 

Public Member Functions

 QMenu (QWidget *parent=nullptr)
 
 QMenu (const QString &title, QWidget *parent=nullptr)
 
 ~QMenu ()
 
QActionaddMenu (QMenu *menu)
 
QMenuaddMenu (const QString &title)
 
QMenuaddMenu (const QIcon &icon, const QString &title)
 
QActionaddSeparator ()
 
QActionaddSection (const QString &text)
 
QActionaddSection (const QIcon &icon, const QString &text)
 
QActioninsertMenu (QAction *before, QMenu *menu)
 
QActioninsertSeparator (QAction *before)
 
QActioninsertSection (QAction *before, const QString &text)
 
QActioninsertSection (QAction *before, const QIcon &icon, const QString &text)
 
bool isEmpty () const
 
void clear ()
 
void setTearOffEnabled (bool)
 
bool isTearOffEnabled () const
 
bool isTearOffMenuVisible () const
 
void showTearOffMenu ()
 
void showTearOffMenu (const QPoint &pos)
 
void hideTearOffMenu ()
 
void setDefaultAction (QAction *)
 
QActiondefaultAction () const
 
void setActiveAction (QAction *act)
 
QActionactiveAction () const
 
void popup (const QPoint &pos, QAction *at=nullptr)
 
QActionexec ()
 
QActionexec (const QPoint &pos, QAction *at=nullptr)
 
QSize sizeHint () const override
 
QRect actionGeometry (QAction *) const
 
QActionactionAt (const QPoint &) const
 
QActionmenuAction () const
 
QString title () const
 
void setTitle (const QString &title)
 
QIcon icon () const
 
void setIcon (const QIcon &icon)
 
void setNoReplayFor (QWidget *widget)
 
QPlatformMenuplatformMenu ()
 
void setPlatformMenu (QPlatformMenu *platformMenu)
 
bool separatorsCollapsible () const
 
void setSeparatorsCollapsible (bool collapse)
 
bool toolTipsVisible () const
 
void setToolTipsVisible (bool visible)
 
void addAction (QAction *action)
 
QActionaddAction (const QString &text)
 
QActionaddAction (const QIcon &icon, const QString &text)
 
QActionaddAction (const QString &text, const QObject *receiver, const char *member, Qt::ConnectionType type=Qt::AutoConnection)
 
QActionaddAction (const QIcon &icon, const QString &text, const QObject *receiver, const char *member, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename... Args, typename = compatible_action_slot_args<Args...>>
QActionaddAction (const QString &text, Args &&...args)
 
template<typename... Args, typename = compatible_action_slot_args<Args...>>
QActionaddAction (const QIcon &icon, const QString &text, Args &&...args)
 
- Public Member Functions inherited from QWidget
 QWidget (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
 
 ~QWidget ()
 
int devType () const override
 
WId winId () const
 
void createWinId ()
 
WId internalWinId () const
 
WId effectiveWinId () const
 
QStylestyle () const
 
void setStyle (QStyle *)
 
bool isWindow () const
 
bool isModal () const
 
Qt::WindowModality windowModality () const
 
void setWindowModality (Qt::WindowModality windowModality)
 
bool isEnabled () const
 
bool isEnabledTo (const QWidget *) const
 
QRect frameGeometry () const
 
const QRectgeometry () const
 
QRect normalGeometry () const
 
int x () const
 
int y () const
 
QPoint pos () const
 
QSize frameSize () const
 
QSize size () const
 
int width () const
 
int height () const
 
QRect rect () const
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
QSize minimumSize () const
 
QSize maximumSize () const
 
int minimumWidth () const
 
int minimumHeight () const
 
int maximumWidth () const
 
int maximumHeight () const
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 
void setMinimumWidth (int minw)
 
void setMinimumHeight (int minh)
 
void setMaximumWidth (int maxw)
 
void setMaximumHeight (int maxh)
 
QSize sizeIncrement () const
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 
QSize baseSize () const
 
void setBaseSize (const QSize &)
 
void setBaseSize (int basew, int baseh)
 
void setFixedSize (const QSize &)
 
void setFixedSize (int w, int h)
 
void setFixedWidth (int w)
 
void setFixedHeight (int h)
 
QPointF mapToGlobal (const QPointF &) const
 
QPoint mapToGlobal (const QPoint &) const
 
QPointF mapFromGlobal (const QPointF &) const
 
QPoint mapFromGlobal (const QPoint &) const
 
QPointF mapToParent (const QPointF &) const
 
QPoint mapToParent (const QPoint &) const
 
QPointF mapFromParent (const QPointF &) const
 
QPoint mapFromParent (const QPoint &) const
 
QPointF mapTo (const QWidget *, const QPointF &) const
 
QPoint mapTo (const QWidget *, const QPoint &) const
 
QPointF mapFrom (const QWidget *, const QPointF &) const
 
QPoint mapFrom (const QWidget *, const QPoint &) const
 
QWidgetwindow () const
 
QWidgetnativeParentWidget () const
 
QWidgettopLevelWidget () const
 
const QPalettepalette () const
 
void setPalette (const QPalette &)
 
void setBackgroundRole (QPalette::ColorRole)
 
QPalette::ColorRole backgroundRole () const
 
void setForegroundRole (QPalette::ColorRole)
 
QPalette::ColorRole foregroundRole () const
 
const QFontfont () const
 
void setFont (const QFont &)
 
QFontMetrics fontMetrics () const
 
QFontInfo fontInfo () const
 
QCursor cursor () const
 
void setCursor (const QCursor &)
 
void unsetCursor ()
 
void setMouseTracking (bool enable)
 
bool hasMouseTracking () const
 
bool underMouse () const
 
void setTabletTracking (bool enable)
 
bool hasTabletTracking () const
 
void setMask (const QBitmap &)
 
void setMask (const QRegion &)
 
QRegion mask () const
 
void clearMask ()
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 
Q_INVOKABLE QPixmap grab (const QRect &rectangle=QRect(QPoint(0, 0), QSize(-1, -1)))
 
void grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags())
 
void ungrabGesture (Qt::GestureType type)
 
QString styleSheet () const
 
QString windowTitle () const
 
void setWindowIcon (const QIcon &icon)
 
QIcon windowIcon () const
 
void setWindowIconText (const QString &)
 
QString windowIconText () const
 
void setWindowRole (const QString &)
 
QString windowRole () const
 
void setWindowFilePath (const QString &filePath)
 
QString windowFilePath () const
 
void setWindowOpacity (qreal level)
 
qreal windowOpacity () const
 
bool isWindowModified () const
 
QString accessibleName () const
 
void setAccessibleName (const QString &name)
 
QString accessibleDescription () const
 
void setAccessibleDescription (const QString &description)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
Qt::LayoutDirection layoutDirection () const
 
void unsetLayoutDirection ()
 
void setLocale (const QLocale &locale)
 
QLocale locale () const
 
void unsetLocale ()
 
bool isRightToLeft () const
 
bool isLeftToRight () const
 
bool isActiveWindow () const
 
void activateWindow ()
 
void clearFocus ()
 
void setFocus (Qt::FocusReason reason)
 
Qt::FocusPolicy focusPolicy () const
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
bool hasFocus () const
 
void setFocusProxy (QWidget *)
 
QWidgetfocusProxy () const
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void grabMouse ()
 
void grabMouse (const QCursor &)
 
void releaseMouse ()
 
void grabKeyboard ()
 
void releaseKeyboard ()
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 
void releaseShortcut (int id)
 
void setShortcutEnabled (int id, bool enable=true)
 
void setShortcutAutoRepeat (int id, bool enable=true)
 
bool updatesEnabled () const
 
void setUpdatesEnabled (bool enable)
 
void update (int x, int y, int w, int h)
 
void update (const QRect &)
 
void update (const QRegion &)
 
void repaint (int x, int y, int w, int h)
 
void repaint (const QRect &)
 
void repaint (const QRegion &)
 
void stackUnder (QWidget *)
 
void move (int x, int y)
 
void move (const QPoint &)
 
void resize (int w, int h)
 
void resize (const QSize &)
 
void setGeometry (int x, int y, int w, int h)
 
void setGeometry (const QRect &)
 
QByteArray saveGeometry () const
 
bool restoreGeometry (const QByteArray &geometry)
 
void adjustSize ()
 
bool isVisible () const
 
bool isVisibleTo (const QWidget *) const
 
bool isHidden () const
 
bool isMinimized () const
 
bool isMaximized () const
 
bool isFullScreen () const
 
Qt::WindowStates windowState () const
 
void setWindowState (Qt::WindowStates state)
 
void overrideWindowState (Qt::WindowStates state)
 
virtual QSize minimumSizeHint () const
 
QSizePolicy sizePolicy () const
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
virtual int heightForWidth (int) const
 
virtual bool hasHeightForWidth () const
 
QRegion visibleRegion () const
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContentsMargins (const QMargins &margins)
 The setContentsMargins function sets the margins around the widget's contents. More...
 
QMargins contentsMargins () const
 The contentsMargins function returns the widget's contents margins. More...
 
QRect contentsRect () const
 
QLayoutlayout () const
 
void setLayout (QLayout *)
 
void updateGeometry ()
 
void setParent (QWidget *parent)
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 
void scroll (int dx, int dy)
 
void scroll (int dx, int dy, const QRect &)
 
QWidgetfocusWidget () const
 
QWidgetnextInFocusChain () const
 
QWidgetpreviousInFocusChain () const
 The previousInFocusChain function returns the previous widget in this widget's focus chain. More...
 
bool acceptDrops () const
 
void setAcceptDrops (bool on)
 
void addAction (QAction *action)
 
void addActions (const QList< QAction * > &actions)
 
void insertActions (QAction *before, const QList< QAction * > &actions)
 
void insertAction (QAction *before, QAction *action)
 
void removeAction (QAction *action)
 
QList< QAction * > actions () const
 
QActionaddAction (const QString &text)
 
QActionaddAction (const QIcon &icon, const QString &text)
 
QActionaddAction (const QString &text, const QObject *receiver, const char *member, Qt::ConnectionType type=Qt::AutoConnection)
 
QActionaddAction (const QIcon &icon, const QString &text, const QObject *receiver, const char *member, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename... Args, typename = compatible_action_slot_args<Args...>>
QActionaddAction (const QString &text, Args &&...args)
 
template<typename... Args, typename = compatible_action_slot_args<Args...>>
QActionaddAction (const QIcon &icon, const QString &text, Args &&...args)
 
QWidgetparentWidget () const
 
void setWindowFlags (Qt::WindowFlags type)
 
Qt::WindowFlags windowFlags () const
 
void setWindowFlag (Qt::WindowType, bool on=true)
 
void overrideWindowFlags (Qt::WindowFlags type)
 
Qt::WindowType windowType () const
 
QWidgetchildAt (int x, int y) const
 
QWidgetchildAt (const QPoint &p) const
 
void setAttribute (Qt::WidgetAttribute, bool on=true)
 
bool testAttribute (Qt::WidgetAttribute) const
 
QPaintEnginepaintEngine () const override
 
void ensurePolished () const
 
bool isAncestorOf (const QWidget *child) const
 
bool autoFillBackground () const
 
void setAutoFillBackground (bool enabled)
 
QBackingStorebackingStore () const
 
QWindowwindowHandle () const
 
QScreenscreen () const
 
void setScreen (QScreen *)
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery) const
 
Qt::InputMethodHints inputMethodHints () const
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 
- Public Member Functions inherited from QPaintDevice
virtual ~QPaintDevice ()
 
bool paintingActive () const
 
int width () const
 
int height () const
 
int widthMM () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
qreal devicePixelRatio () const
 
qreal devicePixelRatioF () const
 
int colorCount () const
 
int depth () const
 

Static Public Member Functions

static QActionexec (const QList< QAction * > &actions, const QPoint &pos, QAction *at=nullptr, QWidget *parent=nullptr)
 
static QMenumenuInAction (const QAction *action)
 
- Static Public Member Functions inherited from QWidget
static void setTabOrder (QWidget *, QWidget *)
 
static QWidgetmouseGrabber ()
 
static QWidgetkeyboardGrabber ()
 
static QWidgetfind (WId)
 
static QWidgetcreateWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Static Public Member Functions inherited from QPaintDevice
static qreal devicePixelRatioFScale ()
 

Protected Member Functions

int columnCount () const
 
void changeEvent (QEvent *) override
 
void keyPressEvent (QKeyEvent *) override
 
void mouseReleaseEvent (QMouseEvent *) override
 
void mousePressEvent (QMouseEvent *) override
 
void mouseMoveEvent (QMouseEvent *) override
 
void enterEvent (QEnterEvent *) override
 
void leaveEvent (QEvent *) override
 
void hideEvent (QHideEvent *) override
 
void paintEvent (QPaintEvent *) override
 
void actionEvent (QActionEvent *) override
 
void timerEvent (QTimerEvent *) override
 
bool event (QEvent *) override
 
bool focusNextPrevChild (bool next) override
 
virtual void initStyleOption (QStyleOptionMenuItem *option, const QAction *action) const
 
- Protected Member Functions inherited from QWidget
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void focusInEvent (QFocusEvent *event)
 
virtual void focusOutEvent (QFocusEvent *event)
 
virtual void moveEvent (QMoveEvent *event)
 
virtual void resizeEvent (QResizeEvent *event)
 
virtual void closeEvent (QCloseEvent *event)
 
virtual void contextMenuEvent (QContextMenuEvent *event)
 
virtual void showEvent (QShowEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, qintptr *result)
 
int metric (PaintDeviceMetric) const override
 
void initPainter (QPainter *painter) const override
 
QPaintDeviceredirected (QPoint *offset) const override
 
QPaintersharedPainter () const override
 
virtual void inputMethodEvent (QInputMethodEvent *)
 
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 
bool focusNextChild ()
 
bool focusPreviousChild ()
 
 QWidget (QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Member Functions inherited from QPaintDevice
 QPaintDevice () noexcept
 

Properties

bool tearOffEnabled
 whether the menu supports being torn off More...
 
QString title
 The title of the menu. More...
 
QIcon icon
 The icon of the menu. More...
 
bool separatorsCollapsible
 whether consecutive separators should be collapsed More...
 
bool toolTipsVisible
 whether tooltips of menu actions should be visible More...
 
- Properties inherited from QWidget
bool modal
 whether the widget is a modal widget More...
 
Qt::WindowModality windowModality
 which windows are blocked by the modal widget More...
 
bool enabled
 whether the widget is enabled More...
 
QRect geometry
 the geometry of the widget relative to its parent and excluding the window frame More...
 
QRect frameGeometry
 geometry of the widget relative to its parent including any window frame More...
 
QRect normalGeometry
 the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget More...
 
int x
 the x coordinate of the widget relative to its parent including any window frame More...
 
int y
 the y coordinate of the widget relative to its parent and including any window frame More...
 
QPoint pos
 the position of the widget within its parent widget More...
 
QSize frameSize
 the size of the widget including any window frame More...
 
QSize size
 the size of the widget excluding any window frame More...
 
int width
 the width of the widget excluding any window frame More...
 
int height
 the height of the widget excluding any window frame More...
 
QRect rect
 the internal geometry of the widget excluding any window frame More...
 
QRect childrenRect
 the bounding rectangle of the widget's children More...
 
QRegion childrenRegion
 the combined region occupied by the widget's children More...
 
QSizePolicy sizePolicy
 the default layout behavior of the widget More...
 
QSize minimumSize
 the widget's minimum size More...
 
QSize maximumSize
 the widget's maximum size in pixels More...
 
int minimumWidth
 the widget's minimum width in pixels More...
 
int minimumHeight
 the widget's minimum height in pixels More...
 
int maximumWidth
 the widget's maximum width in pixels More...
 
int maximumHeight
 the widget's maximum height in pixels More...
 
QSize sizeIncrement
 the size increment of the widget More...
 
QSize baseSize
 the base size of the widget More...
 
QPalette palette
 the widget's palette More...
 
QFont font
 the font currently set for the widget More...
 
QCursor cursor
 the cursor shape for this widget More...
 
bool mouseTracking
 whether mouse tracking is enabled for the widget More...
 
bool tabletTracking
 whether tablet tracking is enabled for the widget More...
 
bool isActiveWindow
 whether this widget's window is the active window More...
 
Qt::FocusPolicy focusPolicy
 the way the widget accepts keyboard focus More...
 
bool focus
 whether this widget (or its focus proxy) has the keyboard input focus More...
 
Qt::ContextMenuPolicy contextMenuPolicy
 how the widget shows a context menu More...
 
bool updatesEnabled
 whether updates are enabled More...
 
bool visible
 whether the widget is visible More...
 
bool minimized
 whether this widget is minimized (iconified) More...
 
bool maximized
 whether this widget is maximized More...
 
bool fullScreen
 whether the widget is shown in full screen mode More...
 
QSize sizeHint
 the recommended size for the widget More...
 
QSize minimumSizeHint
 the recommended minimum size for the widget More...
 
bool acceptDrops
 whether drop events are enabled for this widget More...
 
QString windowTitle
 the window title (caption) More...
 
QIcon windowIcon
 the widget's icon More...
 
QString windowIconText
 the text to be displayed on the icon of a minimized window More...
 
double windowOpacity
 The level of opacity for the window. More...
 
bool windowModified
 whether the document shown in the window has unsaved changes More...
 
QString accessibleName
 the widget's name as seen by assistive technologies More...
 
QString accessibleDescription
 the widget's description as seen by assistive technologies More...
 
Qt::LayoutDirection layoutDirection
 the layout direction for this widget. More...
 
bool autoFillBackground
 whether the widget background is filled automatically More...
 
QString styleSheet
 the widget's style sheet More...
 
QLocale locale
 the widget's locale More...
 
QString windowFilePath
 the file path associated with a widget More...
 
Qt::InputMethodHints inputMethodHints
 What input method specific hints the widget has. More...
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Friends

class QMenuBar
 
class QMenuBarPrivate
 
class QTornOffMenu
 
class QComboBox
 
class QtWidgetsActionPrivate
 
class QToolButtonPrivate
 
void qt_mac_emit_menuSignals (QMenu *menu, bool show)
 
void qt_mac_menu_emit_hovered (QMenu *menu, QAction *action)
 

Additional Inherited Members

- Public Types inherited from QWidget
enum  RenderFlag { DrawWindowBackground = 0x1 , DrawChildren = 0x2 , IgnoreMask = 0x4 }
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1 , PdmHeight , PdmWidthMM , PdmHeightMM ,
  PdmNumColors , PdmDepth , PdmDpiX , PdmDpiY ,
  PdmPhysicalDpiX , PdmPhysicalDpiY , PdmDevicePixelRatio , PdmDevicePixelRatioScaled
}
 
- Public Slots inherited from QWidget
void setEnabled (bool)
 
void setDisabled (bool)
 
void setWindowModified (bool)
 
void setWindowTitle (const QString &)
 
void setStyleSheet (const QString &styleSheet)
 
void setFocus ()
 
void update ()
 
void repaint ()
 
virtual void setVisible (bool visible)
 
void setHidden (bool hidden)
 
void show ()
 
void hide ()
 
void showMinimized ()
 
void showMaximized ()
 
void showFullScreen ()
 
void showNormal ()
 
bool close ()
 
void raise ()
 
void lower ()
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Protected Slots inherited from QWidget
void updateMicroFocus (Qt::InputMethodQuery query=Qt::ImQueryAll)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Attributes inherited from QPaintDevice
ushort painters
 

Detailed Description

The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.

\inmodule QtWidgets

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.

Definition at line 61 of file qmenu.h.

Constructor & Destructor Documentation

◆ QMenu() [1/2]

QMenu::QMenu ( QWidget parent = nullptr)
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 1740 of file qmenu.cpp.

Here is the caller graph for this function:

◆ QMenu() [2/2]

QMenu::QMenu ( const QString title,
QWidget parent = nullptr 
)
explicit

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).

See also
title

Definition at line 1756 of file qmenu.cpp.

◆ ~QMenu()

QMenu::~QMenu ( )

Destroys the menu.

Definition at line 1775 of file qmenu.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ aboutToHide

void QMenu::aboutToHide ( )
signal
Since
4.2

This signal is emitted just before the menu is hidden from the user.

See also
aboutToShow(), hide()
Here is the caller graph for this function:

◆ aboutToShow

void QMenu::aboutToShow ( )
signal

This signal is emitted just before the menu is shown to the user.

See also
aboutToHide(), show()
Here is the caller graph for this function:

◆ actionAt()

QAction * QMenu::actionAt ( const QPoint pt) const

Returns the item at pt; returns \nullptr if there is no item there.

Definition at line 2245 of file qmenu.cpp.

Here is the caller graph for this function:

◆ actionEvent()

void QMenu::actionEvent ( QActionEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 3512 of file qmenu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ actionGeometry()

QRect QMenu::actionGeometry ( QAction act) const

Returns the geometry of action act.

Definition at line 2255 of file qmenu.cpp.

◆ activeAction()

QAction * QMenu::activeAction ( ) const

Returns the currently highlighted action, or \nullptr if no action is currently highlighted.

Definition at line 2187 of file qmenu.cpp.

Here is the caller graph for this function:

◆ addAction() [1/7]

QAction * QWidget::addAction

Definition at line 598 of file qwidget.cpp.

◆ addAction() [2/7]

template<typename... Args, typename = compatible_action_slot_args<Args...>>
QAction* QWidget::addAction ( typename...  Args,
typename  = compatible_action_slot_args<Args...> 
)
inline

Definition at line 611 of file qwidget.h.

◆ addAction() [3/7]

QAction* QWidget::addAction

◆ addAction() [4/7]

QAction * QWidget::addAction

Definition at line 597 of file qwidget.cpp.

◆ addAction() [5/7]

template<typename... Args, typename = compatible_action_slot_args<Args...>>
QAction* QWidget::addAction ( typename...  Args,
typename  = compatible_action_slot_args<Args...> 
)
inline

Definition at line 604 of file qwidget.h.

◆ addAction() [6/7]

QAction* QWidget::addAction

◆ addAction() [7/7]

void QWidget::addAction

Appends the action action to this widget's list of actions.

All QWidgets have a list of \l{QAction}s, however they can be represented graphically in many different ways. The default use of the QAction list (as returned by actions()) is to create a context QMenu.

A QWidget should only have one of each action and adding an action it already has will not cause the same action to be in the widget twice.

The ownership of action is not transferred to this QWidget.

See also
removeAction(), insertAction(), actions(), QMenu

Definition at line 589 of file qwidget.cpp.

Here is the caller graph for this function:

◆ addMenu() [1/3]

QMenu * QMenu::addMenu ( const QIcon icon,
const QString title 
)

Appends a new QMenu with icon and title to the menu. The menu takes ownership of the menu. Returns the new menu.

See also
QWidget::addAction(), QMenu::menuAction()

Definition at line 1897 of file qmenu.cpp.

Here is the call graph for this function:

◆ addMenu() [2/3]

QMenu * QMenu::addMenu ( const QString title)

Appends a new QMenu with title to the menu. The menu takes ownership of the menu. Returns the new menu.

See also
QWidget::addAction(), QMenu::menuAction()

Definition at line 1884 of file qmenu.cpp.

Here is the call graph for this function:

◆ addMenu() [3/3]

QAction * QMenu::addMenu ( QMenu menu)

This convenience function adds menu as a submenu to this menu. It returns menu's menuAction(). This menu does not take ownership of menu.

See also
QWidget::addAction(), QMenu::menuAction()

Definition at line 1871 of file qmenu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addSection() [1/2]

QAction * QMenu::addSection ( const QIcon icon,
const QString text 
)
Since
5.1

This convenience function creates a new section action, i.e. an action with QAction::isSeparator() returning true but also having text and icon hints, and adds the new action to this menu's list of actions. It returns the newly created action.

The rendering of the hints is style and platform dependent. Widget styles can use the text and icon information in the rendering for sections, or can choose to ignore them and render sections like simple separators.

QMenu takes ownership of the returned QAction.

See also
QWidget::addAction()

Definition at line 1963 of file qmenu.cpp.

Here is the call graph for this function:

◆ addSection() [2/2]

QAction * QMenu::addSection ( const QString text)
Since
5.1

This convenience function creates a new section action, i.e. an action with QAction::isSeparator() returning true but also having text hint, and adds the new action to this menu's list of actions. It returns the newly created action.

The rendering of the hint is style and platform dependent. Widget styles can use the text information in the rendering for sections, or can choose to ignore it and render sections like simple separators.

QMenu takes ownership of the returned QAction.

See also
QWidget::addAction()

Definition at line 1939 of file qmenu.cpp.

Here is the call graph for this function:

◆ addSeparator()

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.

QMenu takes ownership of the returned QAction.

See also
QWidget::addAction()

Definition at line 1915 of file qmenu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ changeEvent()

void QMenu::changeEvent ( QEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 2932 of file qmenu.cpp.

Here is the call graph for this function:

◆ clear()

void QMenu::clear ( )

Removes all the menu's actions. Actions owned by the menu and not shown in any other widget are deleted.

See also
removeAction()

Definition at line 2219 of file qmenu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ columnCount()

int QMenu::columnCount ( ) const
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.

Definition at line 2237 of file qmenu.cpp.

◆ defaultAction()

QAction * QMenu::defaultAction ( ) const

Returns the current default action.

See also
setDefaultAction()

Definition at line 2068 of file qmenu.cpp.

◆ enterEvent()

void QMenu::enterEvent ( QEnterEvent )
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 3466 of file qmenu.cpp.

◆ event()

bool QMenu::event ( QEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 2962 of file qmenu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exec() [1/3]

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 \nullptr 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 2602 of file qmenu.cpp.

Here is the caller graph for this function:

◆ exec() [2/3]

QAction * QMenu::exec ( const QList< QAction * > &  actions,
const QPoint pos,
QAction at = nullptr,
QWidget parent = nullptr 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Executes a menu synchronously.

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 \nullptr if no item was triggered (normally because the user pressed Esc).

This is equivalent to:

See also
popup(), QWidget::mapToGlobal()

Definition at line 2691 of file qmenu.cpp.

Here is the call graph for this function:

◆ exec() [3/3]

QAction * QMenu::exec ( const QPoint p,
QAction action = nullptr 
)

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 \nullptr 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.

See also
popup(), QWidget::mapToGlobal()

Definition at line 2643 of file qmenu.cpp.

◆ focusNextPrevChild()

bool QMenu::focusNextPrevChild ( bool  next)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 3053 of file qmenu.cpp.

Here is the call graph for this function:

◆ hideEvent()

void QMenu::hideEvent ( QHideEvent )
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 2701 of file qmenu.cpp.

Here is the call graph for this function:

◆ hideTearOffMenu()

void QMenu::hideTearOffMenu ( )

This function will forcibly hide the torn off menu making it disappear from the user's desktop.

See also
showTearOffMenu(), isTearOffMenuVisible(), isTearOffEnabled()

Definition at line 2157 of file qmenu.cpp.

Here is the caller graph for this function:

◆ hovered

void QMenu::hovered ( QAction action)
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.

See also
triggered(), QAction::hovered()
Here is the caller graph for this function:

◆ icon()

QIcon QMenu::icon ( ) const

Definition at line 1115 of file qmenu.cpp.

◆ initStyleOption()

void QMenu::initStyleOption ( QStyleOptionMenuItem option,
const QAction action 
) const
protectedvirtual

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.

See also
QStyleOption::initFrom(), QMenuBar::initStyleOption()

Definition at line 1593 of file qmenu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertMenu()

QAction * QMenu::insertMenu ( QAction before,
QMenu menu 
)

This convenience function inserts menu before action before and returns the menus menuAction().

See also
QWidget::insertAction(), addMenu()

Definition at line 1977 of file qmenu.cpp.

Here is the call graph for this function:

◆ insertSection() [1/2]

QAction * QMenu::insertSection ( QAction before,
const QIcon icon,
const QString text 
)
Since
5.1

This convenience function creates a new title action, i.e. an action with QAction::isSeparator() returning true but also having text and icon hints. The function inserts the newly created action into this menu's list of actions before action before and returns it.

The rendering of the hints is style and platform dependent. Widget styles can use the text and icon information in the rendering for sections, or can choose to ignore them and render sections like simple separators.

QMenu takes ownership of the returned QAction.

See also
QWidget::insertAction(), addSection()

Definition at line 2043 of file qmenu.cpp.

Here is the call graph for this function:

◆ insertSection() [2/2]

QAction * QMenu::insertSection ( QAction before,
const QString text 
)
Since
5.1

This convenience function creates a new title action, i.e. an action with QAction::isSeparator() returning true but also having text hint. The function inserts the newly created action into this menu's list of actions before action before and returns it.

The rendering of the hint is style and platform dependent. Widget styles can use the text information in the rendering for sections, or can choose to ignore it and render sections like simple separators.

QMenu takes ownership of the returned QAction.

See also
QWidget::insertAction(), addSection()

Definition at line 2019 of file qmenu.cpp.

Here is the call graph for this function:

◆ insertSeparator()

QAction * QMenu::insertSeparator ( QAction before)

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.

QMenu takes ownership of the returned QAction.

See also
QWidget::insertAction(), addSeparator()

Definition at line 1994 of file qmenu.cpp.

Here is the call graph for this function:

◆ isEmpty()

bool QMenu::isEmpty ( ) const
Since
4.2

Returns true if there are no visible actions inserted into the menu, false otherwise.

See also
QWidget::actions()

Definition at line 2201 of file qmenu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isTearOffEnabled()

bool QMenu::isTearOffEnabled ( ) const

Definition at line 2100 of file qmenu.cpp.

◆ isTearOffMenuVisible()

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.

See also
showTearOffMenu(), hideTearOffMenu(), isTearOffEnabled()

Definition at line 2112 of file qmenu.cpp.

◆ keyPressEvent()

void QMenu::keyPressEvent ( QKeyEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Reimplemented in Menu.

Definition at line 3064 of file qmenu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ leaveEvent()

void QMenu::leaveEvent ( QEvent )
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 3477 of file qmenu.cpp.

Here is the call graph for this function:

◆ menuAction()

QAction * QMenu::menuAction ( ) const

Returns the action associated with this menu.

Definition at line 1073 of file qmenu.cpp.

Here is the caller graph for this function:

◆ menuInAction()

static QMenu * QMenu::menuInAction ( const QAction action)
inlinestatic

Returns the menu contained by action, or \nullptr if action does not contain a menu.

In widget applications, actions that contain menus can be used to create menu items with submenus, or inserted into toolbars to create buttons with popup menus.

Definition at line 192 of file qmenu.h.

◆ mouseMoveEvent()

void QMenu::mouseMoveEvent ( QMouseEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 3427 of file qmenu.cpp.

Here is the call graph for this function:

◆ mousePressEvent()

void QMenu::mousePressEvent ( QMouseEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 2874 of file qmenu.cpp.

Here is the call graph for this function:

◆ mouseReleaseEvent()

void QMenu::mouseReleaseEvent ( QMouseEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 2902 of file qmenu.cpp.

◆ paintEvent()

void QMenu::paintEvent ( QPaintEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QWidget.

Definition at line 2730 of file qmenu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ platformMenu()

QPlatformMenu * QMenu::platformMenu ( )

Definition at line 3698 of file qmenu.cpp.

Here is the caller graph for this function:

◆ popup()

void QMenu::popup ( const QPoint p,
QAction atAction = nullptr 
)

Displays the menu so that the action atAction will be at the specified global position p. 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.

See also
QWidget::mapToGlobal(), exec()

Definition at line 2304 of file qmenu.cpp.

Here is the caller graph for this function:

◆ separatorsCollapsible()

bool QMenu::separatorsCollapsible ( ) const

Definition at line 3724 of file qmenu.cpp.

◆ setActiveAction()

void QMenu::setActiveAction ( QAction act)

Sets the currently highlighted action to act.

Definition at line 2174 of file qmenu.cpp.

Here is the caller graph for this function:

◆ setDefaultAction()

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.

See also
defaultAction()

Definition at line 2058 of file qmenu.cpp.

◆ setIcon()

void QMenu::setIcon ( const QIcon icon)

Definition at line 1120 of file qmenu.cpp.

Here is the caller graph for this function:

◆ setNoReplayFor()

void QMenu::setNoReplayFor ( QWidget widget)

Definition at line 3691 of file qmenu.cpp.

◆ setPlatformMenu()

void QMenu::setPlatformMenu ( QPlatformMenu platformMenu)

Definition at line 3706 of file qmenu.cpp.

Here is the call graph for this function:

◆ setSeparatorsCollapsible()

void QMenu::setSeparatorsCollapsible ( bool  collapse)

Definition at line 3730 of file qmenu.cpp.

Here is the call graph for this function:

◆ setTearOffEnabled()

void QMenu::setTearOffEnabled ( bool  b)

Definition at line 2086 of file qmenu.cpp.

Here is the call graph for this function:

◆ setTitle()

void QMenu::setTitle ( const QString title)

Definition at line 1101 of file qmenu.cpp.

Here is the caller graph for this function:

◆ setToolTipsVisible()

void QMenu::setToolTipsVisible ( bool  visible)

Definition at line 3763 of file qmenu.cpp.

◆ showTearOffMenu() [1/2]

void QMenu::showTearOffMenu ( )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.7

This function will forcibly show the torn off menu making it appear on the user's desktop under the mouse currsor.

See also
hideTearOffMenu(), isTearOffMenuVisible(), isTearOffEnabled()

Definition at line 2146 of file qmenu.cpp.

Here is the call graph for this function:

◆ showTearOffMenu() [2/2]

void QMenu::showTearOffMenu ( const QPoint pos)
Since
5.7

This function will forcibly show the torn off menu making it appear on the user's desktop at the specified global position pos.

See also
hideTearOffMenu(), isTearOffMenuVisible(), isTearOffEnabled()

Definition at line 2127 of file qmenu.cpp.

Here is the call graph for this function:

◆ sizeHint()

QSize QMenu::sizeHint ( ) const
overridevirtual

\reimp

Reimplemented from QWidget.

Definition at line 2263 of file qmenu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ timerEvent()

void QMenu::timerEvent ( QTimerEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QObject.

Reimplemented in SubMenuPositionExecMenu.

Definition at line 3489 of file qmenu.cpp.

◆ title()

QString QMenu::title ( ) const

Definition at line 1096 of file qmenu.cpp.

◆ toolTipsVisible()

bool QMenu::toolTipsVisible ( ) const

Definition at line 3757 of file qmenu.cpp.

◆ triggered

void QMenu::triggered ( QAction action)
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 \l{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".

Note
This signal is emitted for the main parent menu in a hierarchy. Hence, only the parent menu needs to be connected to a slot; sub-menus need not be connected.
See also
hovered(), QAction::triggered()
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ QComboBox

friend class QComboBox
friend

Definition at line 261 of file qmenu.h.

◆ QMenuBar

friend class QMenuBar
friend

Definition at line 258 of file qmenu.h.

◆ QMenuBarPrivate

friend class QMenuBarPrivate
friend

Definition at line 259 of file qmenu.h.

◆ qt_mac_emit_menuSignals

void qt_mac_emit_menuSignals ( QMenu menu,
bool  show 
)
friend

◆ qt_mac_menu_emit_hovered

void qt_mac_menu_emit_hovered ( QMenu menu,
QAction action 
)
friend

◆ QToolButtonPrivate

friend class QToolButtonPrivate
friend

Definition at line 263 of file qmenu.h.

◆ QTornOffMenu

friend class QTornOffMenu
friend

Definition at line 260 of file qmenu.h.

◆ QtWidgetsActionPrivate

friend class QtWidgetsActionPrivate
friend

Definition at line 262 of file qmenu.h.

Property Documentation

◆ icon

QMenu::icon
readwrite

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.

Definition at line 268 of file qmenu.h.

◆ separatorsCollapsible

QMenu::separatorsCollapsible
readwrite

whether consecutive separators should be collapsed

Since
4.2

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.

Definition at line 268 of file qmenu.h.

◆ tearOffEnabled

QMenu::tearOffEnabled
readwrite

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.

Definition at line 268 of file qmenu.h.

◆ title

QMenu::title
readwrite

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 268 of file qmenu.h.

◆ toolTipsVisible

QMenu::toolTipsVisible
readwrite

whether tooltips of menu actions should be visible

Since
5.1

This property specifies whether action menu entries show their tooltip.

By default, this property is false.

Definition at line 268 of file qmenu.h.


The documentation for this class was generated from the following files: