![]() |
Qt 6.x
The Qt SDK
|
The QAction class provides an abstraction for user commands that can be added to different user interface components. More...
#include <qaction.h>
Public Types | |
enum | MenuRole { NoRole = 0 , TextHeuristicRole , ApplicationSpecificRole , AboutQtRole , AboutRole , PreferencesRole , QuitRole } |
This enum describes how an action should be moved into the application menu on \macos. More... | |
enum | Priority { LowPriority = 0 , NormalPriority = 128 , HighPriority = 256 } |
This enum defines priorities for actions in user interface. More... | |
enum | ActionEvent { Trigger , Hover } |
This enum type is used when calling QAction::activate() More... | |
Public Slots | |
void | trigger () |
This is a convenience slot that calls activate(Trigger). | |
void | hover () |
This is a convenience slot that calls activate(Hover). | |
void | setChecked (bool) |
void | toggle () |
This is a convenience function for the \l checked property. | |
void | setEnabled (bool) |
void | resetEnabled () |
void | setDisabled (bool b) |
This is a convenience function for the \l enabled property, that is useful for signals–slots connections. | |
void | setVisible (bool) |
![]() | |
void | deleteLater () |
\threadsafe | |
Signals | |
void | changed () |
This signal is emitted when an action has changed. | |
void | enabledChanged (bool enabled) |
void | checkableChanged (bool checkable) |
void | visibleChanged () |
void | triggered (bool checked=false) |
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. | |
void | hovered () |
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. | |
void | toggled (bool) |
This signal is emitted whenever a checkable action changes its isChecked() status. | |
![]() | |
void | destroyed (QObject *=nullptr) |
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
This signal is emitted after the object's name has been changed. | |
Public Member Functions | |
QAction (QObject *parent=nullptr) | |
Constructs an action with parent. | |
QAction (const QString &text, QObject *parent=nullptr) | |
Constructs an action with some text and parent. | |
QAction (const QIcon &icon, const QString &text, QObject *parent=nullptr) | |
Constructs an action with an icon and some text and parent. | |
~QAction () | |
Destroys the object and frees allocated resources. | |
QList< QObject * > | associatedObjects () const |
void | setActionGroup (QActionGroup *group) |
Sets this action group to group. | |
QActionGroup * | actionGroup () const |
Returns the action group for this action. | |
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) |
If b is true then this action will be considered a separator. | |
bool | isSeparator () const |
Returns true if this action is a separator action; otherwise it returns false . | |
void | setFont (const QFont &font) |
QFont | font () const |
void | setCheckable (bool) |
bool | isCheckable () const |
QVariant | data () const |
Returns the user data as set in QAction::setData. | |
void | setData (const QVariant &var) |
Sets the action's internal data to the given data. | |
bool | isChecked () const |
bool | isEnabled () const |
bool | isVisible () const |
void | activate (ActionEvent event) |
Sends the relevant signals for ActionEvent event. | |
void | setMenuRole (MenuRole menuRole) |
MenuRole | menuRole () const |
template<typename T = QMenu*> | |
T | menu () const |
Returns the menu contained by this action. | |
template<typename T = QMenu*> | |
void | setMenu (T m) |
Sets the menu contained by this action to the specified menu. | |
void | setIconVisibleInMenu (bool visible) |
bool | isIconVisibleInMenu () const |
void | setShortcutVisibleInContextMenu (bool show) |
bool | isShortcutVisibleInContextMenu () const |
bool | showStatusText (QObject *object=nullptr) |
Updates the relevant status bar for the UI represented by object by sending a QStatusTipEvent. | |
![]() | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | event (QEvent *event) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
template<typename T > | |
T | findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T > | |
QList< T > | findChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
template<typename T > | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
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 |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false . | |
Protected Member Functions | |
bool | event (QEvent *) override |
\reimp | |
QAction (QActionPrivate &dd, QObject *parent) | |
![]() | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
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 | |
bool | checked |
whether the action is checked. | |
bool | enabled |
whether the action is enabled | |
QIcon | icon |
the action's icon | |
QString | text |
the action's descriptive text | |
QString | iconText |
the action's descriptive icon text | |
QString | toolTip |
the action's tooltip | |
QString | statusTip |
the action's status tip | |
QString | whatsThis |
the action's "What's This?" help text | |
QFont | font |
the action's font | |
bool | visible |
whether the action can be seen (e.g. | |
MenuRole | menuRole |
the action's menu role | |
bool | iconVisibleInMenu |
Whether or not an action should show an icon in a menu. | |
bool | shortcutVisibleInContextMenu |
Whether or not an action should show a shortcut in a context menu. | |
Priority | priority |
the actions's priority in the user interface. | |
![]() | |
QString | objectName |
the name of this object | |
Friends | |
class | QActionGroup |
class | QWidget |
class | QMenu |
class | QMenuPrivate |
class | QToolButton |
class | QGraphicsWidget |
Additional Inherited Members | |
![]() | |
static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
\threadsafe | |
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::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
\threadsafe | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static bool | disconnect (const QMetaObject::Connection &) |
Disconnect a 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) |
![]() | |
QScopedPointer< QObjectData > | d_ptr |
![]() | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) | |
The QAction class provides an abstraction for user commands that can be added to different user interface components.
\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 user interface elements such as menus and toolbars, and will automatically keep the UI 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, descriptive text, icon text, a keyboard shortcut, status text, "What's This?" text, and a tooltip. All properties can be set independently with setIcon(), setText(), setIconText(), setShortcut(), setStatusTip(), setWhatsThis(), and setToolTip(). Icon and text, as the two most important properties, can also be set in the constructor. It's possible to set an individual font with setFont(), which e.g. menus respect when displaying the action as a menu item.
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.
enum QAction::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 |
enum QAction::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 |
enum QAction::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.
Enumerator | |
---|---|
LowPriority | |
NormalPriority | |
HighPriority |
Constructs an action with parent.
If parent is an action group the action will be automatically inserted into the group.
Definition at line 230 of file qaction.cpp.
Constructs an action with some text and parent.
If parent is an action group the action will be automatically inserted into the group.
A stripped version of text (for example, "\&Menu Option..." becomes "Menu Option") will be used for tooltips and icon text unless you specify a different text using setToolTip() or setIconText(), respectively.
Definition at line 246 of file qaction.cpp.
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.
A stripped version of text (for example, "\&Menu Option..." becomes "Menu Option") will be used for tooltips and icon text unless you specify a different text using setToolTip() or setIconText(), respectively.
Definition at line 264 of file qaction.cpp.
QAction::~QAction | ( | ) |
Destroys the object and frees allocated resources.
Definition at line 447 of file qaction.cpp.
References d, QGuiApplicationPrivate::instance(), and qApp.
|
protected |
Definition at line 274 of file qaction.cpp.
References d, and QObject::parent().
QActionGroup * QAction::actionGroup | ( | ) | const |
Returns the action group for this action.
If no action group manages this action, then \nullptr will be returned.
Definition at line 493 of file qaction.cpp.
References d.
Referenced by QMenuPrivate::copyActionToPlatformItem(), and QMenu::initStyleOption().
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 1082 of file qaction.cpp.
References d, emit, QActionGroup::Exclusive, Hover, hovered(), QPointer< T >::isNull(), setChecked(), Trigger, and triggered().
Referenced by QMenuBarPrivate::activateAction(), QMenuPrivate::activateCausedStack(), and event().
Definition at line 505 of file qaction.cpp.
References d.
Referenced by waitForPopup().
|
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.
Referenced by QActionGroup::addAction(), QMenuPrivate::init(), and QActionGroup::removeAction().
|
signal |
QVariant QAction::data | ( | ) | const |
Returns the user data as set in QAction::setData.
Definition at line 1056 of file qaction.cpp.
References d.
Referenced by QCalendarWidgetPrivate::_q_monthChanged(), QDialog::contextMenuEvent(), and setData().
|
signal |
|
overrideprotectedvirtual |
\reimp
Reimplemented from QObject.
Reimplemented in QWidgetAction.
Definition at line 1027 of file qaction.cpp.
References QEvent::ActionChanged, activate(), d, e, QObject::event(), QKeySequence::NativeText, Q_ASSERT_X, qWarning, QCoreApplication::sendEvent(), QEvent::Shortcut, and Trigger.
Referenced by QWidgetAction::event(), and QQuickParentAnimation::transition().
QFont QAction::font | ( | ) | const |
Definition at line 437 of file qaction.cpp.
References d.
|
inlineslot |
|
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.
Referenced by QWidgetPlatformMenuItem::QWidgetPlatformMenuItem(), activate(), QActionGroup::addAction(), QMenuPrivate::insertActionInPlatformMenu(), and QActionGroup::removeAction().
QIcon QAction::icon | ( | ) | const |
Definition at line 554 of file qaction.cpp.
References d.
QString QAction::iconText | ( | ) | const |
Definition at line 661 of file qaction.cpp.
References d, and qt_strippedText().
bool QAction::isCheckable | ( | ) | const |
Definition at line 847 of file qaction.cpp.
References d.
Referenced by QMenuPrivate::copyActionToPlatformItem(), QMenu::initStyleOption(), operator<<(), QToolButton::setDefaultAction(), and QMenuPrivate::updateActionRects().
bool QAction::isChecked | ( | ) | const |
Definition at line 892 of file qaction.cpp.
References d.
Referenced by QFileDialogPrivate::_q_showHeader(), QFileDialogPrivate::_q_showHidden(), QMenuPrivate::copyActionToPlatformItem(), QMenu::initStyleOption(), QPrintPreviewDialogPrivate::isFitting(), operator<<(), QToolButton::setDefaultAction(), and QPrintPreviewDialogPrivate::setFitting().
bool QAction::isEnabled | ( | ) | const |
Definition at line 971 of file qaction.cpp.
References d.
Referenced by QMenuBarPrivate::activateAction(), QMenuPrivate::activateAction(), QMenuPrivate::copyActionToPlatformItem(), QMenuBarPrivate::copyActionToPlatformMenu(), QWidgetAction::event(), QMdiSubWindow::eventFilter(), QMenuBarPrivate::getNextAction(), QMenu::initStyleOption(), QMenuBar::initStyleOption(), QWidgetPlatformMenu::isEnabled(), QMenu::keyPressEvent(), QMenuBar::mousePressEvent(), QMenu::mouseReleaseEvent(), operator<<(), QMenuPrivate::popup(), QMenuBarPrivate::popupAction(), QMenuPrivate::popupAction(), QMenuPrivate::scrollMenu(), QMenuBarPrivate::setCurrentAction(), QMenuPrivate::setCurrentAction(), QToolButton::setDefaultAction(), QWidgetAction::setDefaultWidget(), QMenuPrivate::setFirstActionActive(), and QMenuPrivate::setSyncAction().
bool QAction::isIconVisibleInMenu | ( | ) | const |
Definition at line 1254 of file qaction.cpp.
References Qt::AA_DontShowIconsInMenus, d, and QCoreApplication::testAttribute().
Referenced by QMenuPrivate::copyActionToPlatformItem(), and QMenu::initStyleOption().
bool QAction::isSeparator | ( | ) | const |
Returns true
if this action is a separator action; otherwise it returns false
.
Definition at line 585 of file qaction.cpp.
References d.
Referenced by QMenuPrivate::activateAction(), QMenuBarPrivate::calcActionRects(), QMenuPrivate::copyActionToPlatformItem(), QMenuPrivate::getLastVisibleAction(), QMenu::initStyleOption(), QMenu::isEmpty(), QMenu::keyPressEvent(), QMenu::mouseMoveEvent(), QMenuSloppyState::processMouseEvent(), QMenuPrivate::scrollMenu(), QMenuPrivate::setCurrentAction(), QMenuPrivate::setFirstActionActive(), QMenuPrivate::setSyncAction(), and QMenuPrivate::updateActionRects().
bool QAction::isShortcutVisibleInContextMenu | ( | ) | const |
Definition at line 1290 of file qaction.cpp.
References Qt::AA_DontShowShortcutsInContextMenus, d, and QCoreApplication::testAttribute().
Referenced by QMenu::initStyleOption(), and QMenuPrivate::updateActionRects().
bool QAction::isVisible | ( | ) | const |
Definition at line 1018 of file qaction.cpp.
References d.
Referenced by QMenuBarPrivate::calcActionRects(), QMenuPrivate::copyActionToPlatformItem(), QMenuBarPrivate::copyActionToPlatformMenu(), QMenuPrivate::getLastVisibleAction(), QMenu::isEmpty(), QToolBarItem::isEmpty(), operator<<(), and QMenuPrivate::updateActionRects().
|
inline |
Returns the menu contained by this action.
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 186 of file qaction.h.
Referenced by QMenuBarPrivate::_q_internalShortcutActivated(), QMenuPrivate::copyActionToPlatformItem(), QMenu::event(), QMenuBarPrivate::getPlatformMenu(), QMenu::initStyleOption(), QMenu::keyPressEvent(), QMenu::mouseReleaseEvent(), QMenuBar::mouseReleaseEvent(), QMenuBarPrivate::popupAction(), QMenuPrivate::popupAction(), QToolButton::setDefaultAction(), QMenuPrivate::setSyncAction(), and QMenuSloppyState::timeout().
QAction::MenuRole QAction::menuRole | ( | ) | const |
Definition at line 1190 of file qaction.cpp.
References d.
QAction::Priority QAction::priority | ( | ) | const |
Definition at line 807 of file qaction.cpp.
References d.
|
slot |
Definition at line 962 of file qaction.cpp.
References d.
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.
Definition at line 473 of file qaction.cpp.
References d.
void QAction::setCheckable | ( | bool | b | ) |
Definition at line 832 of file qaction.cpp.
References checkableChanged(), d, emit, and toggled().
Referenced by QFileDialogPrivate::createMenuActions(), QFileDialogPrivate::createWidgets(), QDockWidgetPrivate::init(), QToolBarPrivate::init(), QWidgetPlatformMenuItem::setCheckable(), and QPrintPreviewDialogPrivate::setupActions().
|
slot |
Definition at line 877 of file qaction.cpp.
References d, emit, and toggled().
Referenced by QPrintPreviewDialogPrivate::_q_pageSetup(), activate(), QFileDialogPrivate::createWidgets(), QFileDialogPrivate::restoreWidgetState(), Viewer::setBrightness(), QWidgetPlatformMenuItem::setChecked(), QPrintPreviewDialogPrivate::setFitting(), QPrintPreviewDialogPrivate::setupActions(), and toggle().
Sets the action's internal data to the given data.
Definition at line 1067 of file qaction.cpp.
Referenced by QCalendarWidgetPrivate::createNavigationBar().
|
inlineslot |
|
slot |
Definition at line 927 of file qaction.cpp.
References d, and QAPP_CHECK.
Referenced by QFileDialogPrivate::_q_showContextMenu(), QFileDialogPrivate::createMenuActions(), QUndoGroup::createRedoAction(), QLineEdit::createStandardContextMenu(), QUndoGroup::createUndoAction(), QPrintPreviewDialogPrivate::init(), MainWindow::openFile(), QLineEdit::setClearButtonEnabled(), QWidgetPlatformMenu::setEnabled(), QWidgetPlatformMenuItem::setEnabled(), QMdiSubWindowPrivate::setEnabled(), MainWindow::updateMenus(), and QPrintPreviewDialogPrivate::updateNavActions().
Definition at line 426 of file qaction.cpp.
Referenced by QWidgetPlatformMenuItem::setFont().
Definition at line 547 of file qaction.cpp.
Referenced by qt_setupActionIcon(), setActionIcon(), and QWidgetPlatformMenuItem::setIcon().
Definition at line 651 of file qaction.cpp.
void QAction::setIconVisibleInMenu | ( | bool | visible | ) |
Definition at line 1240 of file qaction.cpp.
References Qt::AA_DontShowIconsInMenus, d, QCoreApplication::testAttribute(), and visible.
|
inline |
Sets the menu contained by this action to the specified menu.
Definition at line 191 of file qaction.h.
Referenced by QMenuPrivate::init(), and QWidgetPlatformMenuItem::setMenu().
Definition at line 1180 of file qaction.cpp.
Referenced by QDockWidgetPrivate::init(), and QWidgetPlatformMenuItem::setRole().
Definition at line 797 of file qaction.cpp.
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.
Definition at line 569 of file qaction.cpp.
References d.
Referenced by QMenu::addSection(), QMenu::addSection(), QMenu::addSeparator(), QToolBar::addSeparator(), QMenu::insertSection(), QMenu::insertSection(), QMenu::insertSeparator(), QMenuBar::insertSeparator(), QToolBar::insertSeparator(), and QWidgetPlatformMenuItem::setIsSeparator().
void QAction::setShortcutVisibleInContextMenu | ( | bool | show | ) |
Definition at line 1276 of file qaction.cpp.
References Qt::AA_DontShowShortcutsInContextMenus, d, QCoreApplication::testAttribute(), and visible.
Definition at line 712 of file qaction.cpp.
References d.
Definition at line 611 of file qaction.cpp.
Referenced by QDockWidgetPrivate::init(), QFileDialogPrivate::retranslateStrings(), and QWidgetPlatformMenuItem::setText().
Definition at line 680 of file qaction.cpp.
References d.
|
slot |
Definition at line 990 of file qaction.cpp.
References d.
Referenced by QWidgetAction::setDefaultWidget(), QWidgetPlatformMenu::setVisible(), QWidgetPlatformMenuItem::setVisible(), and QMdiSubWindowPrivate::setVisible().
Definition at line 752 of file qaction.cpp.
References d.
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.
Definition at line 736 of file qaction.cpp.
Referenced by QMenuBarPrivate::activateAction(), QMenuPrivate::activateAction(), and QMenuPrivate::setCurrentAction().
QString QAction::statusTip | ( | ) | const |
Definition at line 722 of file qaction.cpp.
References d.
QString QAction::text | ( | ) | const |
Definition at line 621 of file qaction.cpp.
References d.
|
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 859 of file qaction.cpp.
References d, and setChecked().
|
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.
Referenced by setCheckable(), and setChecked().
QString QAction::toolTip | ( | ) | const |
Definition at line 690 of file qaction.cpp.
References d, and qt_strippedText().
|
inlineslot |
This is a convenience slot that calls activate(Trigger).
Definition at line 210 of file qaction.h.
References Trigger.
Referenced by QMenuPrivate::insertActionInPlatformMenu().
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.
Referenced by QWidgetPlatformMenuItem::QWidgetPlatformMenuItem(), activate(), QWidget::addAction(), QWidget::addAction(), QActionGroup::addAction(), QUndoGroup::createRedoAction(), QUndoGroup::createUndoAction(), and QActionGroup::removeAction().
|
signal |
QString QAction::whatsThis | ( | ) | const |
Definition at line 762 of file qaction.cpp.
References d.
|
friend |
|
friend |
|
friend |
|
friend |
|
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.
|
readwrite |
|
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).
|
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.
Definition at line 245 of file qaction.h.
Referenced by QMenuPrivate::copyActionToPlatformItem(), QMenu::initStyleOption(), QToolButton::setDefaultAction(), and setFont().
|
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 245 of file qaction.h.
Referenced by QAction(), QMenuBarPrivate::calcActionRects(), QMenuPrivate::copyActionToPlatformItem(), QMenu::initStyleOption(), QMenuBar::initStyleOption(), QToolButton::setDefaultAction(), setIcon(), and QMenuPrivate::updateActionRects().
|
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.
Definition at line 245 of file qaction.h.
Referenced by QToolButton::setDefaultAction().
|
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:
|
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 245 of file qaction.h.
Referenced by QMenuPrivate::copyActionToPlatformItem(), operator<<(), and setMenuRole().
|
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 245 of file qaction.h.
Referenced by setPriority().
|
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.
|
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.
Definition at line 245 of file qaction.h.
Referenced by QToolButton::setDefaultAction(), and showStatusText().
|
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.
Certain UI elements, such as menus or buttons, can use '&' in front of a character to automatically create a mnemonic (a shortcut) for that character. For example, "&File" for a menu will create the shortcut \uicontrol Alt+F, which will open the File menu. "E&xit" will create the shortcut \uicontrol Alt+X for a button, or in a menu allow navigating to the menu item by pressing "x". (use '&&' to display an actual ampersand). The widget might consume and perform an action on a given shortcut.
Definition at line 245 of file qaction.h.
Referenced by QAction(), QCalendarWidgetPrivate::_q_monthChanged(), QMenuBarPrivate::calcActionRects(), QMenuPrivate::copyActionToPlatformItem(), QMenuBarPrivate::copyActionToPlatformMenu(), QMenu::initStyleOption(), QMenuBar::initStyleOption(), QMenu::keyPressEvent(), QMenuBar::keyPressEvent(), operator<<(), setIconText(), setText(), QMenuPrivate::updateActionRects(), and QMenuBarPrivate::updateGeometries().
|
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.
Definition at line 245 of file qaction.h.
Referenced by operator<<(), and QToolButton::setDefaultAction().
|
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 245 of file qaction.h.
Referenced by setIconVisibleInMenu(), and setShortcutVisibleInContextMenu().
|
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.
Definition at line 245 of file qaction.h.
Referenced by QMenuPrivate::activateAction(), QMenu::event(), and QToolButton::setDefaultAction().