Dff2dsf context menu6/23/2023 ![]() QRect QMenu:: actionGeometry( QAction * act) const Reimplements: QWidget::actionEvent(QActionEvent *event). void QMenu:: actionEvent( QActionEvent * e) Returns the item at pt returns nullptr if there is no item there. QAction *QMenu:: actionAt(const QPoint & pt) const This signal is emitted just before the menu is shown to the user. This signal is emitted just before the menu is hidden from the user. QMenu:: QMenu(const QString & title, QWidget * parent = nullptr)Ĭonstructs a menu with a title and a parent.Īlthough 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). Member Function Documentation QMenu:: QMenu( QWidget * parent = nullptr)Īlthough 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). If the QWidgetAction fires the triggered() signal, the menu will close. Instances of this class are used to hold widgets, and are inserted into menus with the addAction() overload that takes a QAction. Widgets can be inserted into menus with the QWidgetAction class. 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. If you want this functionality for a particular menu, insert a tear-off handle with setTearOffEnabled(). This makes it possible for the user to "tear off" frequently used menus and position them in a convenient place on the screen. A tear-off menu is a top-level window that contains a copy of the menu. You clear a menu with clear() and remove individual action items with removeAction().Ī QMenu can also provide a tear-off menu. In addition, QMenu provides two signals, triggered() and hovered(), which signal the QAction that was triggered from the menu. The receiver will be notified whenever the item is triggered(). ![]() When inserting action items you usually specify a receiver and a slot. Separators are inserted with addSeparator(), submenus with addMenu(), and all other items are considered action items. There are four kinds of action items: separators, actions that show a submenu, widgets, and actions that perform an action. The existing actions held by a menu can be found with actions(). 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". An action is represented vertically and rendered by QStyle. Actions are added with the addAction(), addActions() and insertAction() functions. ActionsĪ menu consists of a list of action items. Menus can also be invoked in response to button presses these are just like context menus except for how they are invoked. They can be executed either asynchronously with popup() or synchronously with exec(). Context menus are usually invoked by some special keyboard key or by right-clicking. Use QMenuBar::addMenu() to insert a menu into a menu bar. Pull-down menus are shown by the menu bar when the user clicks on the respective item or presses the specified shortcut key. It can be either a pull-down menu in a menu bar or a standalone context menu. Popup(const QPoint & p, QAction * atAction = nullptr)Ī menu widget is a selection menu. InsertSection(QAction * before, const QIcon & icon, const QString & text) InsertSection(QAction * before, const QString & text) InsertMenu(QAction * before, QMenu * menu) QMenu(const QString & title, QWidget * parent = nullptr)ĪddMenu(const QIcon & icon, const QString & title)ĪddSection(const QIcon & icon, const QString & text)Įxec(const QPoint & p, QAction * action = nullptr)
0 Comments
Leave a Reply. |