[][src]Struct qt_widgets::QWidgetAction

#[repr(C)]pub struct QWidgetAction { /* fields omitted */ }

The QWidgetAction class extends QAction by an interface for inserting custom widgets into action based containers, such as toolbars.

C++ class: QWidgetAction.

C++ documentation:

The QWidgetAction class extends QAction by an interface for inserting custom widgets into action based containers, such as toolbars.

Most actions in an application are represented as items in menus or buttons in toolbars. However sometimes more complex widgets are necessary. For example a zoom action in a word processor may be realized using a QComboBox in a QToolBar, presenting a range of different zoom levels. QToolBar provides QToolBar::insertWidget() as convenience function for inserting a single widget. However if you want to implement an action that uses custom widgets for visualization in multiple containers then you have to subclass QWidgetAction.

If a QWidgetAction is added for example to a QToolBar then QWidgetAction::createWidget() is called. Reimplementations of that function should create a new custom widget with the specified parent.

If the action is removed from a container widget then QWidgetAction::deleteWidget() is called with the previously created custom widget as argument. The default implementation hides the widget and deletes it using QObject::deleteLater().

If you have only one single custom widget then you can set it as default widget using setDefaultWidget(). That widget will then be used if the action is added to a QToolBar, or in general to an action container that supports QWidgetAction. If a QWidgetAction with only a default widget is added to two toolbars at the same time then the default widget is shown only in the first toolbar the action was added to. QWidgetAction takes over ownership of the default widget.

Note that it is up to the widget to activate the action, for example by reimplementing mouse event handlers and calling QAction::trigger().

macOS: If you add a widget to a menu in the application's menu bar on macOS, the widget will be added and it will function but with some limitations:

  1. The widget is reparented away from the QMenu to the native menu view. If you show the menu in some other place (e.g. as a popup menu), the widget will not be there.
  2. Focus/Keyboard handling of the widget is not possible.
  3. Due to Apple's design, mouse tracking on the widget currently does not work.
  4. Connecting the triggered() signal to a slot that opens a modal dialog will cause a crash in macOS 10.4 (known bug acknowledged by Apple), a workaround is to use a QueuedConnection instead of a DirectConnection.

Methods

impl QWidgetAction[src]

pub unsafe fn default_widget(&self) -> QPtr<QWidget>[src]

Returns the default widget.

Calls C++ function: QWidget* QWidgetAction::defaultWidget() const.

C++ documentation:

Returns the default widget.

See also setDefaultWidget().

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QWidgetAction::metaObject() const.

pub unsafe fn new(parent: impl CastInto<Ptr<QObject>>) -> QBox<QWidgetAction>[src]

Constructs an action with parent.

Calls C++ function: [constructor] void QWidgetAction::QWidgetAction(QObject* parent).

C++ documentation:

Constructs an action with parent.

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QWidgetAction::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QWidgetAction::qt_metacast(const char* arg1).

pub unsafe fn release_widget(&self, widget: impl CastInto<Ptr<QWidget>>)[src]

Releases the specified widget.

Calls C++ function: void QWidgetAction::releaseWidget(QWidget* widget).

C++ documentation:

Releases the specified widget.

Container widgets that support actions call this function when a widget action is removed.

See also requestWidget(), deleteWidget(), and defaultWidget().

pub unsafe fn request_widget(
    &self,
    parent: impl CastInto<Ptr<QWidget>>
) -> QPtr<QWidget>
[src]

Returns a widget that represents the action, with the given parent.

Calls C++ function: QWidget* QWidgetAction::requestWidget(QWidget* parent).

C++ documentation:

Returns a widget that represents the action, with the given parent.

Container widgets that support actions can call this function to request a widget as visual representation of the action.

See also releaseWidget(), createWidget(), and defaultWidget().

pub unsafe fn set_default_widget(&self, w: impl CastInto<Ptr<QWidget>>)[src]

Sets widget to be the default widget. The ownership is transferred to QWidgetAction. Unless createWidget() is reimplemented by a subclass to return a new widget the default widget is used when a container widget requests a widget through requestWidget().

Calls C++ function: void QWidgetAction::setDefaultWidget(QWidget* w).

C++ documentation:

Sets widget to be the default widget. The ownership is transferred to QWidgetAction. Unless createWidget() is reimplemented by a subclass to return a new widget the default widget is used when a container widget requests a widget through requestWidget().

See also defaultWidget().

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn tr(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QWidgetAction::tr(const char* s, const char* c, int n).

pub unsafe fn tr_utf8(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QWidgetAction::trUtf8(const char* s, const char* c, int n).

Methods from Deref<Target = QAction>

pub fn slot_trigger(&self) -> Receiver<()>[src]

This is a convenience slot that calls activate(Trigger).

Returns a built-in Qt slot QAction::trigger that can be passed to qt_core::Signal::connect.

C++ documentation:

This is a convenience slot that calls activate(Trigger).

pub fn slot_hover(&self) -> Receiver<()>[src]

This is a convenience slot that calls activate(Hover).

Returns a built-in Qt slot QAction::hover that can be passed to qt_core::Signal::connect.

C++ documentation:

This is a convenience slot that calls activate(Hover).

pub fn slot_set_checked(&self) -> Receiver<(bool,)>[src]

This property holds whether the action is checked.

Returns a built-in Qt slot QAction::setChecked that can be passed to qt_core::Signal::connect.

C++ documentation:

This property holds whether the action is checked.

Only checkable actions can be checked. By default, this is false (the action is unchecked).

Access functions:

bool isChecked() const
void setChecked(bool)

Notifier signal:

void toggled(bool checked)

See also checkable.

pub fn slot_toggle(&self) -> Receiver<()>[src]

This is a convenience function for the checked property. Connect to it to change the checked state to its opposite state.

Returns a built-in Qt slot QAction::toggle that can be passed to qt_core::Signal::connect.

C++ documentation:

This is a convenience function for the checked property. Connect to it to change the checked state to its opposite state.

pub fn slot_set_enabled(&self) -> Receiver<(bool,)>[src]

This property holds whether the action is enabled

Returns a built-in Qt slot QAction::setEnabled that can be passed to qt_core::Signal::connect.

C++ documentation:

This property holds whether the action is enabled

Disabled actions cannot be chosen by the user. They do not disappear from menus or toolbars, but they are displayed in a way which indicates that they are unavailable. For example, they might be displayed using only shades of gray.

What's This? help on disabled actions is still available, provided that the QAction::whatsThis property is set.

An action will be disabled when all widgets to which it is added (with QWidget::addAction()) are disabled or not visible. When an action is disabled, it is not possible to trigger it through its shortcut.

By default, this property is true (actions are enabled).

Access functions:

bool isEnabled() const
void setEnabled(bool)

Notifier signal:

void changed()

See also text.

pub fn slot_set_disabled(&self) -> Receiver<(bool,)>[src]

This is a convenience function for the enabled property, that is useful for signals--slots connections. If b is true the action is disabled; otherwise it is enabled.

Returns a built-in Qt slot QAction::setDisabled that can be passed to qt_core::Signal::connect.

C++ documentation:

This is a convenience function for the enabled property, that is useful for signals--slots connections. If b is true the action is disabled; otherwise it is enabled.

pub fn slot_set_visible(&self) -> Receiver<(bool,)>[src]

This property holds whether the action can be seen (e.g. in menus and toolbars)

Returns a built-in Qt slot QAction::setVisible that can be passed to qt_core::Signal::connect.

C++ documentation:

This property holds whether the action can be seen (e.g. in menus and toolbars)

If visible is true the action can be seen (e.g. in menus and toolbars) and chosen by the user; if visible is false the action cannot be seen or chosen by the user.

Actions which are not visible are not grayed out; they do not appear at all.

By default, this property is true (actions are visible).

Access functions:

bool isVisible() const
void setVisible(bool)

Notifier signal:

void changed()

pub fn changed(&self) -> Signal<()>[src]

This signal is emitted when an action has changed. If you are only interested in actions in a given widget, you can watch for QWidget::actionEvent() sent with an QEvent::ActionChanged.

Returns a built-in Qt signal QAction::changed that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted when an action has changed. If you are only interested in actions in a given widget, you can watch for QWidget::actionEvent() sent with an QEvent::ActionChanged.

Note: Notifier signal for property autoRepeat. Notifier signal for property checkable. Notifier signal for property enabled. Notifier signal for property font. Notifier signal for property icon. Notifier signal for property iconText. Notifier signal for property iconVisibleInMenu. Notifier signal for property menuRole. Notifier signal for property shortcut. Notifier signal for property shortcutContext. Notifier signal for property statusTip. Notifier signal for property text. Notifier signal for property toolTip. Notifier signal for property visible. Notifier signal for property whatsThis.

See also QWidget::actionEvent().

pub fn triggered(&self) -> Signal<(bool,)>[src]

This signal is emitted when an action is activated by the user; for example, when the user clicks a menu option, toolbar button, or presses an action's shortcut key combination, or when trigger() was called. Notably, it is not emitted when setChecked() or toggle() is called.

Returns a built-in Qt signal QAction::triggered that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted when an action is activated by the user; for example, when the user clicks a menu option, toolbar button, or presses an action's shortcut key combination, or when trigger() was called. Notably, it is not emitted when setChecked() or toggle() is called.

If the action is checkable, checked is true if the action is checked, or false if the action is unchecked.

See also QAction::activate(), QAction::toggled(), and checked.

pub fn hovered(&self) -> Signal<()>[src]

This signal is emitted when an action is highlighted by the user; for example, when the user pauses with the cursor over a menu option, toolbar button, or presses an action's shortcut key combination.

Returns a built-in Qt signal QAction::hovered that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted when an action is highlighted by the user; for example, when the user pauses with the cursor over a menu option, toolbar button, or presses an action's shortcut key combination.

See also QAction::activate().

pub fn toggled(&self) -> Signal<(bool,)>[src]

This signal is emitted whenever a checkable action changes its isChecked() status. This can be the result of a user interaction, or because setChecked() was called.

Returns a built-in Qt signal QAction::toggled that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted whenever a checkable action changes its isChecked() status. This can be the result of a user interaction, or because setChecked() was called.

checked is true if the action is checked, or false if the action is unchecked.

Note: Notifier signal for property checked.

See also QAction::activate(), QAction::triggered(), and checked.

pub unsafe fn action_group(&self) -> QPtr<QActionGroup>[src]

Returns the action group for this action. If no action group manages this action then 0 will be returned.

Calls C++ function: QActionGroup* QAction::actionGroup() const.

C++ documentation:

Returns the action group for this action. If no action group manages this action then 0 will be returned.

See also QActionGroup and QAction::setActionGroup().

pub unsafe fn activate(&self, event: ActionEvent)[src]

Sends the relevant signals for ActionEvent event.

Calls C++ function: void QAction::activate(QAction::ActionEvent event).

C++ documentation:

Sends the relevant signals for ActionEvent event.

Action based widgets use this API to cause the QAction to emit signals as well as emitting their own.

pub unsafe fn associated_graphics_widgets(
    &self
) -> CppBox<QListOfQGraphicsWidget>
[src]

Returns a list of widgets this action has been added to.

Calls C++ function: QList<QGraphicsWidget*> QAction::associatedGraphicsWidgets() const.

C++ documentation:

Returns a list of widgets this action has been added to.

This function was introduced in Qt 4.5.

See also QWidget::addAction() and associatedWidgets().

pub unsafe fn associated_widgets(&self) -> CppBox<QListOfQWidget>[src]

Returns a list of widgets this action has been added to.

Calls C++ function: QList<QWidget*> QAction::associatedWidgets() const.

C++ documentation:

Returns a list of widgets this action has been added to.

This function was introduced in Qt 4.2.

See also QWidget::addAction() and associatedGraphicsWidgets().

pub unsafe fn auto_repeat(&self) -> bool[src]

This property holds whether the action can auto repeat

Calls C++ function: bool QAction::autoRepeat() const.

C++ documentation:

This property holds whether the action can auto repeat

If true, the action will auto repeat when the keyboard shortcut combination is held down, provided that keyboard auto repeat is enabled on the system. The default value is true.

This property was introduced in Qt 4.2.

Access functions:

bool autoRepeat() const
void setAutoRepeat(bool)

Notifier signal:

void changed()

pub unsafe fn data(&self) -> CppBox<QVariant>[src]

Returns the user data as set in QAction::setData.

Calls C++ function: QVariant QAction::data() const.

C++ documentation:

Returns the user data as set in QAction::setData.

See also setData().

pub unsafe fn font(&self) -> CppBox<QFont>[src]

This property holds the action's font

Calls C++ function: QFont QAction::font() const.

C++ documentation:

This property holds the action's font

The font property is used to render the text set on the QAction. The font will can be considered a hint as it will not be consulted in all cases based upon application and style.

By default, this property contains the application's default font.

Access functions:

QFont font() const
void setFont(const QFont &font)

Notifier signal:

void changed()

See also QAction::setText() and QStyle.

pub unsafe fn hover(&self)[src]

This is a convenience slot that calls activate(Hover).

Calls C++ function: [slot] void QAction::hover().

C++ documentation:

This is a convenience slot that calls activate(Hover).

pub unsafe fn icon(&self) -> CppBox<QIcon>[src]

This property holds the action's icon

Calls C++ function: QIcon QAction::icon() const.

C++ documentation:

This property holds the action's icon

In toolbars, the icon is used as the tool button icon; in menus, it is displayed to the left of the menu text. There is no default icon.

If a null icon (QIcon::isNull()) is passed into this function, the icon of the action is cleared.

Access functions:

QIcon icon() const
void setIcon(const QIcon &icon)

Notifier signal:

void changed()

pub unsafe fn icon_text(&self) -> CppBox<QString>[src]

This property holds the action's descriptive icon text

Calls C++ function: QString QAction::iconText() const.

C++ documentation:

This property holds the action's descriptive icon text

If QToolBar::toolButtonStyle is set to a value that permits text to be displayed, the text defined held in this property appears as a label in the relevant tool button.

It also serves as the default text in menus and tooltips if the action has not been defined with setText() or setToolTip(), and will also be used in toolbar buttons if no icon has been defined using setIcon().

If the icon text is not explicitly set, the action's normal text will be used for the icon text.

By default, this property contains an empty string.

Access functions:

QString iconText() const
void setIconText(const QString &text)

Notifier signal:

void changed()

See also setToolTip() and setStatusTip().

pub unsafe fn is_checkable(&self) -> bool[src]

This property holds whether the action is a checkable action

Calls C++ function: bool QAction::isCheckable() const.

C++ documentation:

This property holds whether the action is a checkable action

A checkable action is one which has an on/off state. For example, in a word processor, a Bold toolbar button may be either on or off. An action which is not a toggle action is a command action; a command action is simply executed, e.g. file save. By default, this property is false.

In some situations, the state of one toggle action should depend on the state of others. For example, "Left Align", "Center" and "Right Align" toggle actions are mutually exclusive. To achieve exclusive toggling, add the relevant toggle actions to a QActionGroup with the QActionGroup::exclusive property set to true.

Access functions:

bool isCheckable() const
void setCheckable(bool)

Notifier signal:

void changed()

See also QAction::setChecked().

pub unsafe fn is_checked(&self) -> bool[src]

This property holds whether the action is checked.

Calls C++ function: bool QAction::isChecked() const.

C++ documentation:

This property holds whether the action is checked.

Only checkable actions can be checked. By default, this is false (the action is unchecked).

Access functions:

bool isChecked() const
void setChecked(bool)

Notifier signal:

void toggled(bool checked)

See also checkable.

pub unsafe fn is_enabled(&self) -> bool[src]

This property holds whether the action is enabled

Calls C++ function: bool QAction::isEnabled() const.

C++ documentation:

This property holds whether the action is enabled

Disabled actions cannot be chosen by the user. They do not disappear from menus or toolbars, but they are displayed in a way which indicates that they are unavailable. For example, they might be displayed using only shades of gray.

What's This? help on disabled actions is still available, provided that the QAction::whatsThis property is set.

An action will be disabled when all widgets to which it is added (with QWidget::addAction()) are disabled or not visible. When an action is disabled, it is not possible to trigger it through its shortcut.

By default, this property is true (actions are enabled).

Access functions:

bool isEnabled() const
void setEnabled(bool)

Notifier signal:

void changed()

See also text.

pub unsafe fn is_icon_visible_in_menu(&self) -> bool[src]

This property holds whether or not an action should show an icon in a menu

Calls C++ function: bool QAction::isIconVisibleInMenu() const.

C++ documentation:

This property holds whether or not an action should show an icon in a menu

In some applications, it may make sense to have actions with icons in the toolbar, but not in menus. If true, the icon (if valid) is shown in the menu, when it is false, it is not shown.

The default is to follow whether the Qt::AA_DontShowIconsInMenus attribute is set for the application. Explicitly settings this property overrides the presence (or abscence) of the attribute.

For example:

QApplication app(argc, argv); app.setAttribute(Qt::AA_DontShowIconsInMenus); // Icons are no longer shown in menus // ... QAction *myAction = new QAction(); // ... myAction->setIcon(SomeIcon); myAction->setIconVisibleInMenu(true); // Icon will be shown in menus for this action.

This property was introduced in Qt 4.4.

Access functions:

bool isIconVisibleInMenu() const
void setIconVisibleInMenu(bool visible)

Notifier signal:

void changed()

See also QAction::icon and QCoreApplication::setAttribute().

pub unsafe fn is_separator(&self) -> bool[src]

Returns true if this action is a separator action; otherwise it returns false.

Calls C++ function: bool QAction::isSeparator() const.

C++ documentation:

Returns true if this action is a separator action; otherwise it returns false.

See also QAction::setSeparator().

pub unsafe fn is_shortcut_visible_in_context_menu(&self) -> bool[src]

This is supported on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This property holds whether or not an action should show a shortcut in a context menu

Calls C++ function: bool QAction::isShortcutVisibleInContextMenu() const.

C++ documentation:

This property holds whether or not an action should show a shortcut in a context menu

In some applications, it may make sense to have actions with shortcuts in context menus. If true, the shortcut (if valid) is shown when the action is shown via a context menu, when it is false, it is not shown.

The default is to follow whether the Qt::AA_DontShowShortcutsInContextMenus attribute is set for the application, falling back to the widget style hint. Explicitly setting this property overrides the presence (or abscence) of the attribute.

This property was introduced in Qt 5.10.

Access functions:

bool isShortcutVisibleInContextMenu() const
void setShortcutVisibleInContextMenu(bool show)

Notifier signal:

void changed()

See also QAction::shortcut and QCoreApplication::setAttribute().

pub unsafe fn is_visible(&self) -> bool[src]

This property holds whether the action can be seen (e.g. in menus and toolbars)

Calls C++ function: bool QAction::isVisible() const.

C++ documentation:

This property holds whether the action can be seen (e.g. in menus and toolbars)

If visible is true the action can be seen (e.g. in menus and toolbars) and chosen by the user; if visible is false the action cannot be seen or chosen by the user.

Actions which are not visible are not grayed out; they do not appear at all.

By default, this property is true (actions are visible).

Access functions:

bool isVisible() const
void setVisible(bool)

Notifier signal:

void changed()

pub unsafe fn menu(&self) -> QPtr<QMenu>[src]

Returns the menu contained by this action. Actions that contain menus can be used to create menu items with submenus, or inserted into toolbars to create buttons with popup menus.

Calls C++ function: QMenu* QAction::menu() const.

C++ documentation:

Returns the menu contained by this action. Actions that contain menus can be used to create menu items with submenus, or inserted into toolbars to create buttons with popup menus.

See also setMenu() and QMenu::addAction().

pub unsafe fn menu_role(&self) -> MenuRole[src]

This property holds the action's menu role

Calls C++ function: QAction::MenuRole QAction::menuRole() const.

C++ documentation:

This property holds the action's menu role

This indicates what role the action serves in the application menu on macOS. By default all actions have the TextHeuristicRole, which means that the action is added based on its text (see QMenuBar for more information).

The menu role can only be changed before the actions are put into the menu bar in macOS (usually just before the first application window is shown).

This property was introduced in Qt 4.2.

Access functions:

MenuRole menuRole() const
void setMenuRole(MenuRole menuRole)

Notifier signal:

void changed()

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QAction::metaObject() const.

pub unsafe fn parent_widget(&self) -> QPtr<QWidget>[src]

Returns the parent widget.

Calls C++ function: QWidget* QAction::parentWidget() const.

C++ documentation:

Returns the parent widget.

pub unsafe fn priority(&self) -> Priority[src]

This property holds the actions's priority in the user interface.

Calls C++ function: QAction::Priority QAction::priority() const.

C++ documentation:

This property holds the actions's priority in the user interface.

This property can be set to indicate how the action should be prioritized in the user interface.

For instance, when toolbars have the Qt::ToolButtonTextBesideIcon mode set, then actions with LowPriority will not show the text labels.

This property was introduced in Qt 4.6.

Access functions:

Priority priority() const
void setPriority(Priority priority)

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QAction::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QAction::qt_metacast(const char* arg1).

pub unsafe fn set_action_group(&self, group: impl CastInto<Ptr<QActionGroup>>)[src]

Sets this action group to group. The action will be automatically added to the group's list of actions.

Calls C++ function: void QAction::setActionGroup(QActionGroup* group).

C++ documentation:

Sets this action group to group. The action will be automatically added to the group's list of actions.

Actions within the group will be mutually exclusive.

See also QActionGroup and QAction::actionGroup().

pub unsafe fn set_auto_repeat(&self, arg1: bool)[src]

This property holds whether the action can auto repeat

Calls C++ function: void QAction::setAutoRepeat(bool arg1).

C++ documentation:

This property holds whether the action can auto repeat

If true, the action will auto repeat when the keyboard shortcut combination is held down, provided that keyboard auto repeat is enabled on the system. The default value is true.

This property was introduced in Qt 4.2.

Access functions:

bool autoRepeat() const
void setAutoRepeat(bool)

Notifier signal:

void changed()

pub unsafe fn set_checkable(&self, arg1: bool)[src]

This property holds whether the action is a checkable action

Calls C++ function: void QAction::setCheckable(bool arg1).

C++ documentation:

This property holds whether the action is a checkable action

A checkable action is one which has an on/off state. For example, in a word processor, a Bold toolbar button may be either on or off. An action which is not a toggle action is a command action; a command action is simply executed, e.g. file save. By default, this property is false.

In some situations, the state of one toggle action should depend on the state of others. For example, "Left Align", "Center" and "Right Align" toggle actions are mutually exclusive. To achieve exclusive toggling, add the relevant toggle actions to a QActionGroup with the QActionGroup::exclusive property set to true.

Access functions:

bool isCheckable() const
void setCheckable(bool)

Notifier signal:

void changed()

See also QAction::setChecked().

pub unsafe fn set_checked(&self, arg1: bool)[src]

This property holds whether the action is checked.

Calls C++ function: [slot] void QAction::setChecked(bool arg1).

C++ documentation:

This property holds whether the action is checked.

Only checkable actions can be checked. By default, this is false (the action is unchecked).

Access functions:

bool isChecked() const
void setChecked(bool)

Notifier signal:

void toggled(bool checked)

See also checkable.

pub unsafe fn set_data(&self, var: impl CastInto<Ref<QVariant>>)[src]

Sets the action's internal data to the given userData.

Calls C++ function: void QAction::setData(const QVariant& var).

C++ documentation:

Sets the action's internal data to the given userData.

See also data().

pub unsafe fn set_disabled(&self, b: bool)[src]

This is a convenience function for the enabled property, that is useful for signals--slots connections. If b is true the action is disabled; otherwise it is enabled.

Calls C++ function: [slot] void QAction::setDisabled(bool b).

C++ documentation:

This is a convenience function for the enabled property, that is useful for signals--slots connections. If b is true the action is disabled; otherwise it is enabled.

pub unsafe fn set_enabled(&self, arg1: bool)[src]

This property holds whether the action is enabled

Calls C++ function: [slot] void QAction::setEnabled(bool arg1).

C++ documentation:

This property holds whether the action is enabled

Disabled actions cannot be chosen by the user. They do not disappear from menus or toolbars, but they are displayed in a way which indicates that they are unavailable. For example, they might be displayed using only shades of gray.

What's This? help on disabled actions is still available, provided that the QAction::whatsThis property is set.

An action will be disabled when all widgets to which it is added (with QWidget::addAction()) are disabled or not visible. When an action is disabled, it is not possible to trigger it through its shortcut.

By default, this property is true (actions are enabled).

Access functions:

bool isEnabled() const
void setEnabled(bool)

Notifier signal:

void changed()

See also text.

pub unsafe fn set_font(&self, font: impl CastInto<Ref<QFont>>)[src]

This property holds the action's font

Calls C++ function: void QAction::setFont(const QFont& font).

C++ documentation:

This property holds the action's font

The font property is used to render the text set on the QAction. The font will can be considered a hint as it will not be consulted in all cases based upon application and style.

By default, this property contains the application's default font.

Access functions:

QFont font() const
void setFont(const QFont &font)

Notifier signal:

void changed()

See also QAction::setText() and QStyle.

pub unsafe fn set_icon(&self, icon: impl CastInto<Ref<QIcon>>)[src]

This property holds the action's icon

Calls C++ function: void QAction::setIcon(const QIcon& icon).

C++ documentation:

This property holds the action's icon

In toolbars, the icon is used as the tool button icon; in menus, it is displayed to the left of the menu text. There is no default icon.

If a null icon (QIcon::isNull()) is passed into this function, the icon of the action is cleared.

Access functions:

QIcon icon() const
void setIcon(const QIcon &icon)

Notifier signal:

void changed()

pub unsafe fn set_icon_text(&self, text: impl CastInto<Ref<QString>>)[src]

This property holds the action's descriptive icon text

Calls C++ function: void QAction::setIconText(const QString& text).

C++ documentation:

This property holds the action's descriptive icon text

If QToolBar::toolButtonStyle is set to a value that permits text to be displayed, the text defined held in this property appears as a label in the relevant tool button.

It also serves as the default text in menus and tooltips if the action has not been defined with setText() or setToolTip(), and will also be used in toolbar buttons if no icon has been defined using setIcon().

If the icon text is not explicitly set, the action's normal text will be used for the icon text.

By default, this property contains an empty string.

Access functions:

QString iconText() const
void setIconText(const QString &text)

Notifier signal:

void changed()

See also setToolTip() and setStatusTip().

pub unsafe fn set_icon_visible_in_menu(&self, visible: bool)[src]

This property holds whether or not an action should show an icon in a menu

Calls C++ function: void QAction::setIconVisibleInMenu(bool visible).

C++ documentation:

This property holds whether or not an action should show an icon in a menu

In some applications, it may make sense to have actions with icons in the toolbar, but not in menus. If true, the icon (if valid) is shown in the menu, when it is false, it is not shown.

The default is to follow whether the Qt::AA_DontShowIconsInMenus attribute is set for the application. Explicitly settings this property overrides the presence (or abscence) of the attribute.

For example:

QApplication app(argc, argv); app.setAttribute(Qt::AA_DontShowIconsInMenus); // Icons are no longer shown in menus // ... QAction *myAction = new QAction(); // ... myAction->setIcon(SomeIcon); myAction->setIconVisibleInMenu(true); // Icon will be shown in menus for this action.

This property was introduced in Qt 4.4.

Access functions:

bool isIconVisibleInMenu() const
void setIconVisibleInMenu(bool visible)

Notifier signal:

void changed()

See also QAction::icon and QCoreApplication::setAttribute().

pub unsafe fn set_menu(&self, menu: impl CastInto<Ptr<QMenu>>)[src]

Sets the menu contained by this action to the specified menu.

Calls C++ function: void QAction::setMenu(QMenu* menu).

C++ documentation:

Sets the menu contained by this action to the specified menu.

See also menu().

pub unsafe fn set_menu_role(&self, menu_role: MenuRole)[src]

This property holds the action's menu role

Calls C++ function: void QAction::setMenuRole(QAction::MenuRole menuRole).

C++ documentation:

This property holds the action's menu role

This indicates what role the action serves in the application menu on macOS. By default all actions have the TextHeuristicRole, which means that the action is added based on its text (see QMenuBar for more information).

The menu role can only be changed before the actions are put into the menu bar in macOS (usually just before the first application window is shown).

This property was introduced in Qt 4.2.

Access functions:

MenuRole menuRole() const
void setMenuRole(MenuRole menuRole)

Notifier signal:

void changed()

pub unsafe fn set_priority(&self, priority: Priority)[src]

This property holds the actions's priority in the user interface.

Calls C++ function: void QAction::setPriority(QAction::Priority priority).

C++ documentation:

This property holds the actions's priority in the user interface.

This property can be set to indicate how the action should be prioritized in the user interface.

For instance, when toolbars have the Qt::ToolButtonTextBesideIcon mode set, then actions with LowPriority will not show the text labels.

This property was introduced in Qt 4.6.

Access functions:

Priority priority() const
void setPriority(Priority priority)

pub unsafe fn set_separator(&self, b: bool)[src]

If b is true then this action will be considered a separator.

Calls C++ function: void QAction::setSeparator(bool b).

C++ documentation:

If b is true then this action will be considered a separator.

How a separator is represented depends on the widget it is inserted into. Under most circumstances the text, submenu, and icon will be ignored for separator actions.

See also QAction::isSeparator().

pub unsafe fn set_shortcut(&self, shortcut: impl CastInto<Ref<QKeySequence>>)[src]

This property holds the action's primary shortcut key

Calls C++ function: void QAction::setShortcut(const QKeySequence& shortcut).

C++ documentation:

This property holds the action's primary shortcut key

Valid keycodes for this property can be found in Qt::Key and Qt::Modifier. There is no default shortcut key.

Access functions:

QKeySequence shortcut() const
void setShortcut(const QKeySequence &shortcut)

Notifier signal:

void changed()

pub unsafe fn set_shortcut_context(&self, context: ShortcutContext)[src]

This property holds the context for the action's shortcut

Calls C++ function: void QAction::setShortcutContext(Qt::ShortcutContext context).

C++ documentation:

This property holds the context for the action's shortcut

Valid values for this property can be found in Qt::ShortcutContext. The default value is Qt::WindowShortcut.

Access functions:

Qt::ShortcutContext shortcutContext() const
void setShortcutContext(Qt::ShortcutContext context)

Notifier signal:

void changed()

pub unsafe fn set_shortcut_visible_in_context_menu(&self, show: bool)[src]

This is supported on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This property holds whether or not an action should show a shortcut in a context menu

Calls C++ function: void QAction::setShortcutVisibleInContextMenu(bool show).

C++ documentation:

This property holds whether or not an action should show a shortcut in a context menu

In some applications, it may make sense to have actions with shortcuts in context menus. If true, the shortcut (if valid) is shown when the action is shown via a context menu, when it is false, it is not shown.

The default is to follow whether the Qt::AA_DontShowShortcutsInContextMenus attribute is set for the application, falling back to the widget style hint. Explicitly setting this property overrides the presence (or abscence) of the attribute.

This property was introduced in Qt 5.10.

Access functions:

bool isShortcutVisibleInContextMenu() const
void setShortcutVisibleInContextMenu(bool show)

Notifier signal:

void changed()

See also QAction::shortcut and QCoreApplication::setAttribute().

pub unsafe fn set_shortcuts_q_list_of_q_key_sequence(
    &self,
    shortcuts: impl CastInto<Ref<QListOfQKeySequence>>
)
[src]

Sets shortcuts as the list of shortcuts that trigger the action. The first element of the list is the primary shortcut.

Calls C++ function: void QAction::setShortcuts(const QList<QKeySequence>& shortcuts).

C++ documentation:

Sets shortcuts as the list of shortcuts that trigger the action. The first element of the list is the primary shortcut.

This function was introduced in Qt 4.2.

See also shortcuts() and shortcut.

pub unsafe fn set_shortcuts_standard_key(&self, arg1: StandardKey)[src]

Sets a platform dependent list of shortcuts based on the key. The result of calling this function will depend on the currently running platform. Note that more than one shortcut can assigned by this action. If only the primary shortcut is required, use setShortcut instead.

Calls C++ function: void QAction::setShortcuts(QKeySequence::StandardKey arg1).

C++ documentation:

Sets a platform dependent list of shortcuts based on the key. The result of calling this function will depend on the currently running platform. Note that more than one shortcut can assigned by this action. If only the primary shortcut is required, use setShortcut instead.

This function was introduced in Qt 4.2.

See also QKeySequence::keyBindings().

pub unsafe fn set_status_tip(&self, status_tip: impl CastInto<Ref<QString>>)[src]

This property holds the action's status tip

Calls C++ function: void QAction::setStatusTip(const QString& statusTip).

C++ documentation:

This property holds the action's status tip

The status tip is displayed on all status bars provided by the action's top-level parent widget.

By default, this property contains an empty string.

Access functions:

QString statusTip() const
void setStatusTip(const QString &statusTip)

Notifier signal:

void changed()

See also setToolTip() and showStatusText().

pub unsafe fn set_text(&self, text: impl CastInto<Ref<QString>>)[src]

This property holds the action's descriptive text

Calls C++ function: void QAction::setText(const QString& text).

C++ documentation:

This property holds the action's descriptive text

If the action is added to a menu, the menu option will consist of the icon (if there is one), the text, and the shortcut (if there is one). If the text is not explicitly set in the constructor, or by using setText(), the action's description icon text will be used as text. There is no default text.

Access functions:

QString text() const
void setText(const QString &text)

Notifier signal:

void changed()

See also iconText.

pub unsafe fn set_tool_tip(&self, tip: impl CastInto<Ref<QString>>)[src]

This property holds the action's tooltip

Calls C++ function: void QAction::setToolTip(const QString& tip).

C++ documentation:

This property holds the action's tooltip

This text is used for the tooltip. If no tooltip is specified, the action's text is used.

By default, this property contains the action's text.

Access functions:

QString toolTip() const
void setToolTip(const QString &tip)

Notifier signal:

void changed()

See also setStatusTip() and setShortcut().

pub unsafe fn set_visible(&self, arg1: bool)[src]

This property holds whether the action can be seen (e.g. in menus and toolbars)

Calls C++ function: [slot] void QAction::setVisible(bool arg1).

C++ documentation:

This property holds whether the action can be seen (e.g. in menus and toolbars)

If visible is true the action can be seen (e.g. in menus and toolbars) and chosen by the user; if visible is false the action cannot be seen or chosen by the user.

Actions which are not visible are not grayed out; they do not appear at all.

By default, this property is true (actions are visible).

Access functions:

bool isVisible() const
void setVisible(bool)

Notifier signal:

void changed()

pub unsafe fn set_whats_this(&self, what: impl CastInto<Ref<QString>>)[src]

This property holds the action's "What's This?" help text

Calls C++ function: void QAction::setWhatsThis(const QString& what).

C++ documentation:

This property holds the action's "What's This?" help text

The "What's This?" text is used to provide a brief description of the action. The text may contain rich text. There is no default "What's This?" text.

Access functions:

QString whatsThis() const
void setWhatsThis(const QString &what)

Notifier signal:

void changed()

See also QWhatsThis.

pub unsafe fn shortcut(&self) -> CppBox<QKeySequence>[src]

This property holds the action's primary shortcut key

Calls C++ function: QKeySequence QAction::shortcut() const.

C++ documentation:

This property holds the action's primary shortcut key

Valid keycodes for this property can be found in Qt::Key and Qt::Modifier. There is no default shortcut key.

Access functions:

QKeySequence shortcut() const
void setShortcut(const QKeySequence &shortcut)

Notifier signal:

void changed()

pub unsafe fn shortcut_context(&self) -> ShortcutContext[src]

This property holds the context for the action's shortcut

Calls C++ function: Qt::ShortcutContext QAction::shortcutContext() const.

C++ documentation:

This property holds the context for the action's shortcut

Valid values for this property can be found in Qt::ShortcutContext. The default value is Qt::WindowShortcut.

Access functions:

Qt::ShortcutContext shortcutContext() const
void setShortcutContext(Qt::ShortcutContext context)

Notifier signal:

void changed()

pub unsafe fn shortcuts(&self) -> CppBox<QListOfQKeySequence>[src]

Returns the list of shortcuts, with the primary shortcut as the first element of the list.

Calls C++ function: QList<QKeySequence> QAction::shortcuts() const.

C++ documentation:

Returns the list of shortcuts, with the primary shortcut as the first element of the list.

This function was introduced in Qt 4.2.

See also setShortcuts().

pub unsafe fn show_status_text_1a(
    &self,
    widget: impl CastInto<Ptr<QWidget>>
) -> bool
[src]

Updates the relevant status bar for the widget specified by sending a QStatusTipEvent to its parent widget. Returns true if an event was sent; otherwise returns false.

Calls C++ function: bool QAction::showStatusText(QWidget* widget = …).

C++ documentation:

Updates the relevant status bar for the widget specified by sending a QStatusTipEvent to its parent widget. Returns true if an event was sent; otherwise returns false.

If a null widget is specified, the event is sent to the action's parent.

See also statusTip.

pub unsafe fn show_status_text_0a(&self) -> bool[src]

Updates the relevant status bar for the widget specified by sending a QStatusTipEvent to its parent widget. Returns true if an event was sent; otherwise returns false.

Calls C++ function: bool QAction::showStatusText().

C++ documentation:

Updates the relevant status bar for the widget specified by sending a QStatusTipEvent to its parent widget. Returns true if an event was sent; otherwise returns false.

If a null widget is specified, the event is sent to the action's parent.

See also statusTip.

pub unsafe fn status_tip(&self) -> CppBox<QString>[src]

This property holds the action's status tip

Calls C++ function: QString QAction::statusTip() const.

C++ documentation:

This property holds the action's status tip

The status tip is displayed on all status bars provided by the action's top-level parent widget.

By default, this property contains an empty string.

Access functions:

QString statusTip() const
void setStatusTip(const QString &statusTip)

Notifier signal:

void changed()

See also setToolTip() and showStatusText().

pub unsafe fn text(&self) -> CppBox<QString>[src]

This property holds the action's descriptive text

Calls C++ function: QString QAction::text() const.

C++ documentation:

This property holds the action's descriptive text

If the action is added to a menu, the menu option will consist of the icon (if there is one), the text, and the shortcut (if there is one). If the text is not explicitly set in the constructor, or by using setText(), the action's description icon text will be used as text. There is no default text.

Access functions:

QString text() const
void setText(const QString &text)

Notifier signal:

void changed()

See also iconText.

pub unsafe fn toggle(&self)[src]

This is a convenience function for the checked property. Connect to it to change the checked state to its opposite state.

Calls C++ function: [slot] void QAction::toggle().

C++ documentation:

This is a convenience function for the checked property. Connect to it to change the checked state to its opposite state.

pub unsafe fn tool_tip(&self) -> CppBox<QString>[src]

This property holds the action's tooltip

Calls C++ function: QString QAction::toolTip() const.

C++ documentation:

This property holds the action's tooltip

This text is used for the tooltip. If no tooltip is specified, the action's text is used.

By default, this property contains the action's text.

Access functions:

QString toolTip() const
void setToolTip(const QString &tip)

Notifier signal:

void changed()

See also setStatusTip() and setShortcut().

pub unsafe fn trigger(&self)[src]

This is a convenience slot that calls activate(Trigger).

Calls C++ function: [slot] void QAction::trigger().

C++ documentation:

This is a convenience slot that calls activate(Trigger).

pub unsafe fn whats_this(&self) -> CppBox<QString>[src]

This property holds the action's "What's This?" help text

Calls C++ function: QString QAction::whatsThis() const.

C++ documentation:

This property holds the action's "What's This?" help text

The "What's This?" text is used to provide a brief description of the action. The text may contain rich text. There is no default "What's This?" text.

Access functions:

QString whatsThis() const
void setWhatsThis(const QString &what)

Notifier signal:

void changed()

See also QWhatsThis.

Trait Implementations

impl CppDeletable for QWidgetAction[src]

unsafe fn delete(&self)[src]

Destroys the object and frees allocated resources.

Calls C++ function: virtual [destructor] void QWidgetAction::~QWidgetAction().

C++ documentation:

Destroys the object and frees allocated resources.

impl Deref for QWidgetAction[src]

type Target = QAction

The resulting type after dereferencing.

fn deref(&self) -> &QAction[src]

Calls C++ function: QAction* static_cast<QAction*>(QWidgetAction* ptr).

impl DynamicCast<QWidgetAction> for QAction[src]

unsafe fn dynamic_cast(ptr: Ptr<QAction>) -> Ptr<QWidgetAction>[src]

Calls C++ function: QWidgetAction* dynamic_cast<QWidgetAction*>(QAction* ptr).

impl DynamicCast<QWidgetAction> for QObject[src]

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QWidgetAction>[src]

Calls C++ function: QWidgetAction* dynamic_cast<QWidgetAction*>(QObject* ptr).

impl StaticDowncast<QWidgetAction> for QAction[src]

unsafe fn static_downcast(ptr: Ptr<QAction>) -> Ptr<QWidgetAction>[src]

Calls C++ function: QWidgetAction* static_cast<QWidgetAction*>(QAction* ptr).

impl StaticDowncast<QWidgetAction> for QObject[src]

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QWidgetAction>[src]

Calls C++ function: QWidgetAction* static_cast<QWidgetAction*>(QObject* ptr).

impl StaticUpcast<QAction> for QWidgetAction[src]

unsafe fn static_upcast(ptr: Ptr<QWidgetAction>) -> Ptr<QAction>[src]

Calls C++ function: QAction* static_cast<QAction*>(QWidgetAction* ptr).

impl StaticUpcast<QObject> for QWidgetAction[src]

unsafe fn static_upcast(ptr: Ptr<QWidgetAction>) -> Ptr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QWidgetAction* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.