QMenuProxy Class
Header: | #include <QMenuProxy> |
Inherits: | QObject |
Public Types
enum | PopupPlacement { FloatingPopup, TopPosedLeftAlignedPopup, TopPosedRightAlignedPopup, LeftPosedTopAlignedPopup, LeftPosedBottomAlignedPopup, …, RightPosedBottomAlignedPopup } |
Public Functions
void | addMenuItem(const QString &text) |
void | addMenuItem(QMenuItem *item, QMenuItem *before = nullptr) |
void | addSection(const QString &text) |
void | clearMenuItems() |
void | close() |
QQmlListProperty<QMenuItem> | content() |
int | maximumWidth() const |
int | minimumWidth() const |
void | open(int x = 0, int y = 0) |
void | openRelative() |
QMenuProxy::PopupPlacement | placement() const |
bool | preferSeamlessEdges() const |
void | removeMenuItem(QMenuItem *item) |
void | resetMaximumWidth() |
void | setMaximumWidth(int maximumWidth) |
void | setMinimumWidth(int width) |
void | setPlacement(QMenuProxy::PopupPlacement placement) |
void | setPreferSeamlessEdges(bool request) |
void | setTransientParent(QWindow *parent) |
void | setVisualParent(QObject *parent) |
QMenuProxy::Status | status() const |
QWindow * | transientParent() |
QObject * | visualParent() const |
Signals
void | maximumWidthChanged() |
void | minimumWidthChanged() |
void | placementChanged() |
void | preferSeamlessEdgesChanged() |
void | statusChanged() |
void | transientParentChanged() |
Detailed Description
@class Menu
An Item provides a menu for use in context specific situations. You can specify the position for the menu to open by setting its visualParent. MenuItems should be used to draw entries in the menu. The open() function opens up the menu at the given visualParent.
Example usage: @code import org.kde.plasma.extras 2.0 as PlasmaExtras
[...] PlasmaExtras.Menu { id: menu ... PlasmaExtras.MenuItem { text: "Delete" onClicked: { myListItem.remove(); } } } PlasmaExtras.Button { id: btn onClicked: { menu.visualParent = btn menu.open() } } [...] @endcode
Member Type Documentation
enum QMenuProxy::PopupPlacement
The popup position enumeration relatively to his attached widget
Member Function Documentation
[invokable]
void QMenuProxy::addMenuItem(const QString &text)
This adds a menu item from a String
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
void QMenuProxy::addMenuItem(QMenuItem *item, QMenuItem *before = nullptr)
This adds MenuItem 'item' to the menu before MenuItem 'before'. If MenuItem 'before' is 0 or does not exist in the menu, 'item' is appended to the menu instead. If MenuItem 'item' already exists in the menu, it is removed and inserted at the new position.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
void QMenuProxy::addSection(const QString &text)
This adds a section header with a string used as name for the section
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
void QMenuProxy::clearMenuItems()
This removes all menuItems inside the menu
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
void QMenuProxy::close()
This closes the menu
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
void QMenuProxy::open(int x = 0, int y = 0)
This opens the menu at position x,y on the given visualParent. By default x and y are set to 0
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
void QMenuProxy::openRelative()
This opens the menu at the specified placement relative to the visualParent.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
void QMenuProxy::removeMenuItem(QMenuItem *item)
This removes MenuItem 'item'
@since 5.27
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.