QtBase  v6.3.1
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | Friends | List of all members
QAction Class Reference

The QAction class provides an abstraction for user commands that can be added to different user interface components. More...

#include <qaction.h>

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

Public Types

enum  MenuRole {
  NoRole = 0 , TextHeuristicRole , ApplicationSpecificRole , AboutQtRole ,
  AboutRole , PreferencesRole , QuitRole
}
 
enum  Priority { LowPriority = 0 , NormalPriority = 128 , HighPriority = 256 }
 
enum  ActionEvent { Trigger , Hover }
 

Public Slots

void trigger ()
 
void hover ()
 
void setChecked (bool)
 
void toggle ()
 
void setEnabled (bool)
 
void resetEnabled ()
 
void setDisabled (bool b)
 
void setVisible (bool)
 
- Public Slots inherited from QObject
void deleteLater ()
 

Signals

void changed ()
 
void enabledChanged (bool enabled)
 
void checkableChanged (bool checkable)
 
void visibleChanged ()
 
void triggered (bool checked=false)
 
void hovered ()
 
void toggled (bool)
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 

Public Member Functions

 QAction (QObject *parent=nullptr)
 
 QAction (const QString &text, QObject *parent=nullptr)
 
 QAction (const QIcon &icon, const QString &text, QObject *parent=nullptr)
 
 ~QAction ()
 
QList< QObject * > associatedObjects () const
 
void setActionGroup (QActionGroup *group)
 
QActionGroupactionGroup () const
 
void setIcon (const QIcon &icon)
 
QIcon icon () const
 
void setText (const QString &text)
 
QString text () const
 
void setIconText (const QString &text)
 
QString iconText () const
 
void setToolTip (const QString &tip)
 
QString toolTip () const
 
void setStatusTip (const QString &statusTip)
 
QString statusTip () const
 
void setWhatsThis (const QString &what)
 
QString whatsThis () const
 
void setPriority (Priority priority)
 
Priority priority () const
 
void setSeparator (bool b)
 
bool isSeparator () const
 
void setFont (const QFont &font)
 
QFont font () const
 
void setCheckable (bool)
 
bool isCheckable () const
 
QVariant data () const
 
void setData (const QVariant &var)
 
bool isChecked () const
 
bool isEnabled () const
 
bool isVisible () const
 
void activate (ActionEvent event)
 
void setMenuRole (MenuRole menuRole)
 
MenuRole menuRole () const
 
void setIconVisibleInMenu (bool visible)
 
bool isIconVisibleInMenu () const
 
void setShortcutVisibleInContextMenu (bool show)
 
bool isShortcutVisibleInContextMenu () const
 
bool showStatusText (QObject *object=nullptr)
 
- 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
 

Protected Member Functions

bool event (QEvent *) override
 
 QAction (QActionPrivate &dd, QObject *parent)
 
- 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 timerEvent (QTimerEvent *event)
 
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)
 

Properties

bool checkable
 whether the action is a checkable action More...
 
bool checked
 whether the action is checked. More...
 
bool enabled
 whether the action is enabled More...
 
QIcon icon
 the action's icon More...
 
QString text
 the action's descriptive text More...
 
QString iconText
 the action's descriptive icon text More...
 
QString toolTip
 the action's tooltip More...
 
QString statusTip
 the action's status tip More...
 
QString whatsThis
 the action's "What's This?" help text More...
 
QFont font
 the action's font More...
 
bool visible
 whether the action can be seen (e.g. in menus and toolbars) More...
 
MenuRole menuRole
 the action's menu role More...
 
bool iconVisibleInMenu
 Whether or not an action should show an icon in a menu. More...
 
bool shortcutVisibleInContextMenu
 Whether or not an action should show a shortcut in a context menu. More...
 
Priority priority
 the actions's priority in the user interface. More...
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Friends

class QActionGroup
 
class QWidget
 
class QMenu
 
class QMenuPrivate
 
class QToolButton
 
class QGraphicsWidget
 

Additional Inherited Members

- 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)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

The QAction class provides an abstraction for user commands that can be added to different user interface components.

Since
6.0

\inmodule QtGui

In applications many common commands can be invoked via menus, toolbar buttons, and keyboard shortcuts. Since the user expects each command to be performed in the same way, regardless of the user interface used, it is useful to represent each command as an action.

Actions can be added to menus and toolbars, and will automatically keep them in sync. For example, in a word processor, if the user presses a Bold toolbar button, the Bold menu item will automatically be checked.

A QAction may contain an icon, menu text, a shortcut, status text, "What's This?" text, and a tooltip. Most of these can be set in the constructor. They can also be set independently with setIcon(), setText(), setIconText(), setShortcut(), setStatusTip(), setWhatsThis(), and setToolTip(). For menu items, it is possible to set an individual font with setFont().

We recommend that actions are created as children of the window they are used in. In most cases actions will be children of the application's main window.

Definition at line 64 of file qaction.h.

Member Enumeration Documentation

◆ ActionEvent

This enum type is used when calling QAction::activate()

\value Trigger this will cause the QAction::triggered() signal to be emitted.

\value Hover this will cause the QAction::hovered() signal to be emitted.

Enumerator
Trigger 
Hover 

Definition at line 207 of file qaction.h.

◆ MenuRole

This enum describes how an action should be moved into the application menu on \macos.

\value NoRole This action should not be put into the application menu \value TextHeuristicRole This action should be put in the application menu based on the action's text as described in the QMenuBar documentation. \value ApplicationSpecificRole This action should be put in the application menu with an application specific role \value AboutQtRole This action handles the "About Qt" menu item. \value AboutRole This action should be placed where the "About" menu item is in the application menu. The text of the menu item will be set to "About <application name>". The application name is fetched from the {Info.plist} file in the application's bundle (See \l{Qt for macOS - Deployment}). \value PreferencesRole This action should be placed where the "Preferences..." menu item is in the application menu. \value QuitRole This action should be placed where the Quit menu item is in the application menu.

Setting this value only has effect on items that are in the immediate menus of the menubar, not the submenus of those menus. For example, if you have File menu in your menubar and the File menu has a submenu, setting the MenuRole for the actions in that submenu have no effect. They will never be moved.

Enumerator
NoRole 
TextHeuristicRole 
ApplicationSpecificRole 
AboutQtRole 
AboutRole 
PreferencesRole 
QuitRole 

Definition at line 96 of file qaction.h.

◆ Priority

This enum defines priorities for actions in user interface.

\value LowPriority The action should not be prioritized in the user interface.

\value NormalPriority

\value HighPriority The action should be prioritized in the user interface.

See also
priority
Enumerator
LowPriority 
NormalPriority 
HighPriority 

Definition at line 99 of file qaction.h.

Constructor & Destructor Documentation

◆ QAction() [1/4]

QAction::QAction ( QObject parent = nullptr)
explicit

Constructs an action with parent. If parent is an action group the action will be automatically inserted into the group.

Note
The parent argument is optional since Qt 5.7.

Definition at line 265 of file qaction.cpp.

◆ QAction() [2/4]

QAction::QAction ( const QString text,
QObject parent = nullptr 
)
explicit

Constructs an action with some text and parent. If parent is an action group the action will be automatically inserted into the group.

The action uses a stripped version of text (e.g. "\&Menu Option..." becomes "Menu Option") as descriptive text for tool buttons. You can override this by setting a specific description with setText(). The same text will be used for tooltips unless you specify a different text using setToolTip().

Definition at line 283 of file qaction.cpp.

◆ QAction() [3/4]

QAction::QAction ( const QIcon icon,
const QString text,
QObject parent = nullptr 
)
explicit

Constructs an action with an icon and some text and parent. If parent is an action group the action will be automatically inserted into the group.

The action uses a stripped version of text (e.g. "\&Menu Option..." becomes "Menu Option") as descriptive text for tool buttons. You can override this by setting a specific description with setText(). The same text will be used for tooltips unless you specify a different text using setToolTip().

Definition at line 302 of file qaction.cpp.

◆ ~QAction()

QAction::~QAction ( )

Destroys the object and frees allocated resources.

Definition at line 485 of file qaction.cpp.

Here is the call graph for this function:

◆ QAction() [4/4]

QAction::QAction ( QActionPrivate dd,
QObject parent 
)
protected

Definition at line 312 of file qaction.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ actionGroup()

QActionGroup * QAction::actionGroup ( ) const

Returns the action group for this action. If no action group manages this action, then \nullptr will be returned.

See also
QActionGroup, setActionGroup()

Definition at line 531 of file qaction.cpp.

◆ activate()

void QAction::activate ( ActionEvent  event)

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.

Definition at line 1112 of file qaction.cpp.

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

◆ associatedObjects()

QList< QObject * > QAction::associatedObjects ( ) const
Since
6.0 Returns a list of objects this action has been added to.
See also
QWidget::addAction(), QGraphicsWidget::addAction()

Definition at line 543 of file qaction.cpp.

◆ changed

void QAction::changed ( )
signal

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.

See also
QWidget::actionEvent()
Here is the caller graph for this function:

◆ checkableChanged

void QAction::checkableChanged ( bool  checkable)
signal
Here is the caller graph for this function:

◆ data()

QVariant QAction::data ( ) const

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

See also
setData()

Definition at line 1086 of file qaction.cpp.

Here is the caller graph for this function:

◆ enabledChanged

void QAction::enabledChanged ( bool  enabled)
signal

◆ event()

bool QAction::event ( QEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QObject.

Reimplemented in QWidgetAction.

Definition at line 1057 of file qaction.cpp.

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

◆ font()

QFont QAction::font ( ) const

Definition at line 475 of file qaction.cpp.

◆ hover

void QAction::hover ( )
inlineslot

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

Definition at line 245 of file qaction.h.

◆ hovered

void QAction::hovered ( )
signal

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
activate()
Here is the caller graph for this function:

◆ icon()

QIcon QAction::icon ( ) const

Definition at line 592 of file qaction.cpp.

◆ iconText()

QString QAction::iconText ( ) const

Definition at line 691 of file qaction.cpp.

◆ isCheckable()

bool QAction::isCheckable ( ) const

Definition at line 877 of file qaction.cpp.

◆ isChecked()

bool QAction::isChecked ( ) const

Definition at line 922 of file qaction.cpp.

Here is the caller graph for this function:

◆ isEnabled()

bool QAction::isEnabled ( ) const

Definition at line 1001 of file qaction.cpp.

Here is the caller graph for this function:

◆ isIconVisibleInMenu()

bool QAction::isIconVisibleInMenu ( ) const

Definition at line 1286 of file qaction.cpp.

Here is the call graph for this function:

◆ isSeparator()

bool QAction::isSeparator ( ) const

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

See also
setSeparator()

Definition at line 623 of file qaction.cpp.

Here is the caller graph for this function:

◆ isShortcutVisibleInContextMenu()

bool QAction::isShortcutVisibleInContextMenu ( ) const

Definition at line 1322 of file qaction.cpp.

Here is the call graph for this function:

◆ isVisible()

bool QAction::isVisible ( ) const

Definition at line 1048 of file qaction.cpp.

Here is the caller graph for this function:

◆ menuRole()

QAction::MenuRole QAction::menuRole ( ) const

Definition at line 1220 of file qaction.cpp.

◆ priority()

QAction::Priority QAction::priority ( ) const

Definition at line 837 of file qaction.cpp.

◆ resetEnabled

void QAction::resetEnabled ( )
slot

Definition at line 992 of file qaction.cpp.

◆ setActionGroup()

void QAction::setActionGroup ( QActionGroup group)

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, actionGroup()

Definition at line 511 of file qaction.cpp.

◆ setCheckable()

void QAction::setCheckable ( bool  b)

Definition at line 862 of file qaction.cpp.

Here is the caller graph for this function:

◆ setChecked

void QAction::setChecked ( bool  b)
slot

Definition at line 907 of file qaction.cpp.

Here is the caller graph for this function:

◆ setData()

void QAction::setData ( const QVariant data)

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

See also
data()

Definition at line 1097 of file qaction.cpp.

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

◆ setDisabled

void QAction::setDisabled ( bool  b)
inlineslot

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

Definition at line 250 of file qaction.h.

Here is the caller graph for this function:

◆ setEnabled

void QAction::setEnabled ( bool  b)
slot

Definition at line 957 of file qaction.cpp.

Here is the caller graph for this function:

◆ setFont()

void QAction::setFont ( const QFont font)

Definition at line 464 of file qaction.cpp.

◆ setIcon()

void QAction::setIcon ( const QIcon icon)

Definition at line 585 of file qaction.cpp.

Here is the caller graph for this function:

◆ setIconText()

void QAction::setIconText ( const QString text)

Definition at line 681 of file qaction.cpp.

◆ setIconVisibleInMenu()

void QAction::setIconVisibleInMenu ( bool  visible)

Definition at line 1272 of file qaction.cpp.

Here is the call graph for this function:

◆ setMenuRole()

void QAction::setMenuRole ( MenuRole  menuRole)

Definition at line 1210 of file qaction.cpp.

Here is the caller graph for this function:

◆ setPriority()

void QAction::setPriority ( Priority  priority)

Definition at line 827 of file qaction.cpp.

◆ setSeparator()

void QAction::setSeparator ( bool  b)

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
isSeparator()

Definition at line 607 of file qaction.cpp.

Here is the caller graph for this function:

◆ setShortcutVisibleInContextMenu()

void QAction::setShortcutVisibleInContextMenu ( bool  show)

Definition at line 1308 of file qaction.cpp.

Here is the call graph for this function:

◆ setStatusTip()

void QAction::setStatusTip ( const QString statusTip)

Definition at line 742 of file qaction.cpp.

Here is the caller graph for this function:

◆ setText()

void QAction::setText ( const QString text)

Definition at line 641 of file qaction.cpp.

Here is the caller graph for this function:

◆ setToolTip()

void QAction::setToolTip ( const QString tip)

Definition at line 710 of file qaction.cpp.

◆ setVisible

void QAction::setVisible ( bool  b)
slot

Definition at line 1020 of file qaction.cpp.

Here is the caller graph for this function:

◆ setWhatsThis()

void QAction::setWhatsThis ( const QString what)

Definition at line 782 of file qaction.cpp.

◆ showStatusText()

bool QAction::showStatusText ( QObject object = nullptr)

Updates the relevant status bar for the UI represented by object by sending a QStatusTipEvent. 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

Definition at line 766 of file qaction.cpp.

Here is the caller graph for this function:

◆ statusTip()

QString QAction::statusTip ( ) const

Definition at line 752 of file qaction.cpp.

◆ text()

QString QAction::text ( ) const

Definition at line 651 of file qaction.cpp.

Here is the caller graph for this function:

◆ toggle

void QAction::toggle ( )
slot

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

Definition at line 889 of file qaction.cpp.

Here is the call graph for this function:

◆ toggled

void QAction::toggled ( bool  checked)
signal

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. As setChecked() changes the QAction, it emits changed() in addition to toggled().

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

See also
activate(), triggered(), checked
Here is the caller graph for this function:

◆ toolTip()

QString QAction::toolTip ( ) const

Definition at line 720 of file qaction.cpp.

◆ trigger

void QAction::trigger ( )
inlineslot

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

Definition at line 244 of file qaction.h.

Here is the caller graph for this function:

◆ triggered

void QAction::triggered ( bool  checked = false)
signal

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
activate(), toggled(), checked
Here is the caller graph for this function:

◆ visibleChanged

void QAction::visibleChanged ( )
signal

◆ whatsThis()

QString QAction::whatsThis ( ) const

Definition at line 792 of file qaction.cpp.

Friends And Related Function Documentation

◆ QActionGroup

friend class QActionGroup
friend

Definition at line 264 of file qaction.h.

◆ QGraphicsWidget

friend class QGraphicsWidget
friend

Definition at line 269 of file qaction.h.

◆ QMenu

friend class QMenu
friend

Definition at line 266 of file qaction.h.

◆ QMenuPrivate

friend class QMenuPrivate
friend

Definition at line 267 of file qaction.h.

◆ QToolButton

friend class QToolButton
friend

Definition at line 268 of file qaction.h.

◆ QWidget

friend class QWidget
friend

Definition at line 265 of file qaction.h.

Property Documentation

◆ checkable

QAction::checkable
readwrite

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.

See also
setChecked()

Definition at line 279 of file qaction.h.

◆ checked

QAction::checked
readwrite

whether the action is checked.

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

Note
The notifier signal for this property is toggled(). As toggling a QAction changes its state, it will also emit a changed() signal.
See also
checkable, toggled()

Definition at line 279 of file qaction.h.

◆ enabled

QAction::enabled
readwrite

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.

\uicontrol{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).

See also
text

Definition at line 279 of file qaction.h.

◆ font

QAction::font
readwrite

the action's font

The font property is used to render the text set on the QAction. The font 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.

See also
setText()

Definition at line 279 of file qaction.h.

◆ icon

QAction::icon
readwrite

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.

Definition at line 279 of file qaction.h.

◆ iconText

QAction::iconText
readwrite

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.

See also
setToolTip(), setStatusTip()

Definition at line 279 of file qaction.h.

◆ iconVisibleInMenu

QAction::iconVisibleInMenu
readwrite

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 absence) of the attribute.

For example:

See also
icon, QCoreApplication::setAttribute()

Definition at line 279 of file qaction.h.

◆ menuRole

QAction::menuRole
readwrite

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

Definition at line 279 of file qaction.h.

◆ priority

QAction::priority
readwrite

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.

Definition at line 279 of file qaction.h.

◆ shortcutVisibleInContextMenu

QAction::shortcutVisibleInContextMenu
readwrite

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. Explicitly setting this property overrides the attribute.

See also
shortcut, QCoreApplication::setAttribute()

Definition at line 279 of file qaction.h.

◆ statusTip

QAction::statusTip
readwrite

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.

See also
setToolTip(), showStatusText()

Definition at line 279 of file qaction.h.

◆ text

QAction::text
readwrite

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.

See also
iconText

Definition at line 279 of file qaction.h.

◆ toolTip

QAction::toolTip
readwrite

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.

See also
setStatusTip(), setShortcut()

Definition at line 279 of file qaction.h.

◆ visible

QAction::visible
readwrite

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

Definition at line 279 of file qaction.h.

◆ whatsThis

QAction::whatsThis
readwrite

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.

See also
QWhatsThis

Definition at line 279 of file qaction.h.


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