Qt 4.8
|
The QAction class provides an abstract user interface action that can be inserted into widgets. More...
#include <qaction.h>
Public Types | |
enum | ActionEvent { Trigger, Hover } |
This enum type is used when calling QAction::activate() More... | |
enum | MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole, AboutRole, PreferencesRole, QuitRole } |
This enum describes how an action should be moved into the application menu on Mac OS X. More... | |
enum | Priority { LowPriority = 0, NormalPriority = 128, HighPriority = 256 } |
This enum defines priorities for actions in user interface. More... | |
enum | SoftKeyRole { NoSoftKey, PositiveSoftKey, NegativeSoftKey, SelectSoftKey } |
This enum describes how an action should be placed in the softkey bar. More... | |
Public Slots | |
void | hover () |
This is a convenience slot that calls activate(Hover). More... | |
void | setChecked (bool) |
void | setDisabled (bool b) |
This is a convenience function for the enabled property, that is useful for signals–slots connections. More... | |
void | setEnabled (bool) |
void | setVisible (bool) |
void | toggle () |
This is a convenience function for the checked property. More... | |
void | trigger () |
This is a convenience slot that calls activate(Trigger). More... | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Signals | |
void | changed () |
This signal is emitted when an action has changed. More... | |
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. More... | |
void | toggled (bool) |
This signal is emitted whenever a checkable action changes its isChecked() status. More... | |
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. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
QActionGroup * | actionGroup () const |
Returns the action group for this action. More... | |
void | activate (ActionEvent event) |
Sends the relevant signals for ActionEvent event. More... | |
QList< QGraphicsWidget * > | associatedGraphicsWidgets () const |
Returns a list of widgets this action has been added to. More... | |
QList< QWidget * > | associatedWidgets () const |
Returns a list of widgets this action has been added to. More... | |
bool | autoRepeat () const |
QVariant | data () const |
Returns the user data as set in QAction::setData. More... | |
QFont | font () const |
QIcon | icon () const |
QString | iconText () const |
bool | isCheckable () const |
bool | isChecked () const |
bool | isEnabled () const |
bool | isIconVisibleInMenu () const |
bool | isSeparator () const |
Returns true if this action is a separator action; otherwise it returns false. More... | |
bool | isVisible () const |
QMenu * | menu () const |
Returns the menu contained by this action. More... | |
MenuRole | menuRole () const |
QWidget * | parentWidget () const |
Returns the parent widget. More... | |
Priority | priority () const |
QAction (QObject *parent) | |
Constructs an action with parent. More... | |
QAction (const QString &text, QObject *parent) | |
Constructs an action with some text and parent. More... | |
QAction (const QIcon &icon, const QString &text, QObject *parent) | |
Constructs an action with an icon and some text and parent. More... | |
void | setActionGroup (QActionGroup *group) |
Sets this action group to group. More... | |
void | setAutoRepeat (bool) |
void | setCheckable (bool) |
void | setData (const QVariant &var) |
Sets the action's internal data to the given userData. More... | |
void | setFont (const QFont &font) |
void | setIcon (const QIcon &icon) |
void | setIconText (const QString &text) |
void | setIconVisibleInMenu (bool visible) |
void | setMenu (QMenu *menu) |
Sets the menu contained by this action to the specified menu. More... | |
void | setMenuRole (MenuRole menuRole) |
void | setPriority (Priority priority) |
void | setSeparator (bool b) |
If b is true then this action will be considered a separator. More... | |
void | setShortcut (const QKeySequence &shortcut) |
void | setShortcutContext (Qt::ShortcutContext context) |
void | setShortcuts (const QList< QKeySequence > &shortcuts) |
Sets shortcuts as the list of shortcuts that trigger the action. More... | |
void | setShortcuts (QKeySequence::StandardKey) |
Sets a platform dependent list of shortcuts based on the key. More... | |
void | setSoftKeyRole (SoftKeyRole softKeyRole) |
void | setStatusTip (const QString &statusTip) |
void | setText (const QString &text) |
void | setToolTip (const QString &tip) |
void | setWhatsThis (const QString &what) |
QKeySequence | shortcut () const |
Qt::ShortcutContext | shortcutContext () const |
QList< QKeySequence > | shortcuts () const |
Returns the list of shortcuts, with the primary shortcut as the first element of the list. More... | |
bool | showStatusText (QWidget *widget=0) |
Updates the relevant status bar for the widget specified by sending a QStatusTipEvent to its parent widget. More... | |
SoftKeyRole | softKeyRole () const |
QString | statusTip () const |
QString | text () const |
QString | toolTip () const |
QString | whatsThis () const |
~QAction () | |
Destroys the object and frees allocated resources. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) 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. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
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. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Protected Functions | |
bool | event (QEvent *) |
Reimplemented Function More... | |
QAction (QActionPrivate &dd, QObject *parent) | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
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 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Properties | |
bool | autoRepeat |
whether the action can auto repeat More... | |
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... | |
QFont | font |
the action's font More... | |
QIcon | icon |
the action's icon More... | |
QString | iconText |
the action's descriptive icon text More... | |
bool | iconVisibleInMenu |
Whether or not an action should show an icon in a menu. More... | |
MenuRole | menuRole |
the action's menu role More... | |
Priority | priority |
the actions's priority in the user interface. More... | |
QKeySequence | shortcut |
the action's primary shortcut key More... | |
Qt::ShortcutContext | shortcutContext |
the context for the action's shortcut More... | |
SoftKeyRole | softKeyRole |
the action's softkey role More... | |
QString | statusTip |
the action's status tip More... | |
QString | text |
the action's descriptive text More... | |
QString | toolTip |
the action's tooltip More... | |
bool | visible |
whether the action can be seen (e.g. More... | |
QString | whatsThis |
the action's "What's This?" help text More... | |
Friends | |
class | QActionGroup |
class | QGraphicsWidget |
class | QMenu |
class | QMenuBar |
class | QMenuPrivate |
class | QShortcutMap |
void | qt_mac_clear_status_text (QAction *action) |
class | QToolButton |
class | QWidget |
Additional Inherited Members | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QAction class provides an abstract user interface action that can be inserted into widgets.
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.
Actions can be created as independent objects, but they may also be created during the construction of menus; the QMenu class contains convenience functions for creating actions suitable for use as menu items.
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().
Actions are added to widgets using QWidget::addAction() or QGraphicsWidget::addAction(). Note that an action must be added to a widget before it can be used; this is also true when the shortcut should be global (i.e., Qt::ApplicationShortcut as Qt::ShortcutContext).
Once a QAction has been created it should be added to the relevant menu and toolbar, then connected to the slot which will perform the action. For example:
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()
Enumerator | |
---|---|
Trigger | |
Hover |
Definition at line 176 of file qaction.h.
enum QAction::MenuRole |
This enum describes how an action should be moved into the application menu on Mac OS X.
Info.plist
file in the application's bundle (See Deploying an Application on Mac OS X). 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 94 of file qaction.h.
enum QAction::Priority |
This enum defines priorities for actions in user interface.
Enumerator | |
---|---|
LowPriority | |
NormalPriority | |
HighPriority |
enum QAction::SoftKeyRole |
This enum describes how an action should be placed in the softkey bar.
Currently this enum only has an effect on the Symbian platform.
Actions with a softkey role defined are only visible in the softkey bar when the widget containing the action has focus. If no widget currently has focus, the softkey framework will traverse up the widget parent hierarchy looking for a widget containing softkey actions.
Enumerator | |
---|---|
NoSoftKey | |
PositiveSoftKey | |
NegativeSoftKey | |
SelectSoftKey |
|
explicit |
Constructs an action with parent.
If parent is an action group the action will be automatically inserted into the group.
Definition at line 328 of file qaction.cpp.
Referenced by setFont().
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 351 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.
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 373 of file qaction.cpp.
QAction::~QAction | ( | ) |
Destroys the object and frees allocated resources.
Definition at line 694 of file qaction.cpp.
|
protected |
Definition at line 387 of file qaction.cpp.
QActionGroup * QAction::actionGroup | ( | ) | const |
Returns the action group for this action.
If no action group manages this action then 0 will be returned.
Definition at line 747 of file qaction.cpp.
Referenced by QMenu::initStyleOption(), and QMenuPrivate::QMacMenuPrivate::syncAction().
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 1326 of file qaction.cpp.
Referenced by QMenuBarPrivate::activateAction(), QMenuPrivate::activateCausedStack(), event(), qt_mac_activate_action(), and QMenuBarPrivate::wceEmitSignals().
QList< QGraphicsWidget * > QAction::associatedGraphicsWidgets | ( | ) | const |
Returns a list of widgets this action has been added to.
Definition at line 432 of file qaction.cpp.
Returns a list of widgets this action has been added to.
Definition at line 416 of file qaction.cpp.
Referenced by QDialogButtonBox::event(), and waitForPopup().
bool QAction::autoRepeat | ( | ) | const |
Referenced by setAutoRepeat().
|
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.
QVariant QAction::data | ( | ) | const |
Returns the user data as set in QAction::setData.
Definition at line 1280 of file qaction.cpp.
Referenced by QCalendarWidgetPrivate::_q_monthChanged(), QmlJSDebugger::QmlToolBar::changeAnimationSpeed(), QMultiInputContext::changeSlave(), QmlJSDebugger::LiveSelectionTool::contextMenuElementHovered(), QmlJSDebugger::LiveSelectionTool::contextMenuElementSelected(), QmlJSDebugger::QmlToolBar::setAnimationSpeed(), and setData().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QObject.
Reimplemented in QWidgetAction.
Definition at line 1256 of file qaction.cpp.
Referenced by QWidgetAction::event().
|
inlineslot |
This is a convenience slot that calls activate(Hover).
Definition at line 219 of file qaction.h.
|
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 activate().
QString QAction::iconText | ( | ) | const |
Referenced by setIconText().
bool QAction::isCheckable | ( | ) | const |
Definition at line 1105 of file qaction.cpp.
Referenced by QMenu::initStyleOption(), qt_wce_insert_action(), QToolButton::setDefaultAction(), and QMenuPrivate::updateActionRects().
bool QAction::isChecked | ( | ) | const |
Definition at line 1151 of file qaction.cpp.
Referenced by QActionGroupPrivate::_q_actionChanged(), QFileDialogPrivate::_q_showHeader(), QFileDialogPrivate::_q_showHidden(), QWhatsThisAction::actionTriggered(), QActionGroup::addAction(), QAxServerBase::createPopup(), QMenu::initStyleOption(), qt_wce_insert_action(), QToolButton::setDefaultAction(), QPrintPreviewDialogPrivate::setFitting(), QAccessibleMenu::state(), QAccessibleMenuItem::state(), and QMenuPrivate::QMacMenuPrivate::syncAction().
bool QAction::isEnabled | ( | ) | const |
Definition at line 1208 of file qaction.cpp.
Referenced by QMenuBarPrivate::activateAction(), QMenuPrivate::activateAction(), QAxServerBase::createMenu(), QAxServerBase::createPopup(), QAccessibleMenu::doAction(), QAccessibleMenuBar::doAction(), QWidgetAction::event(), QMenuBarPrivate::getNextAction(), QMenuBar::initStyleOption(), QMenu::initStyleOption(), QMenu::keyPressEvent(), QMenu::popup(), QMenuBarPrivate::popupAction(), QMenuPrivate::popupAction(), qt_mac_set_modal_state(), qt_mac_set_modal_state_helper_recursive(), qt_wce_insert_action(), QMenuPrivate::scrollMenu(), QToolButton::setDefaultAction(), QWidgetAction::setDefaultWidget(), QMenuPrivate::setFirstActionActive(), QMenuPrivate::setMacMenuEnabled(), QMenuPrivate::setSyncAction(), QAccessibleMenu::state(), QAccessibleMenuBar::state(), QAccessibleMenuItem::state(), QMenuBarPrivate::QMacMenuBarPrivate::syncAction(), and QMenuPrivate::QMacMenuPrivate::syncAction().
bool QAction::isIconVisibleInMenu | ( | ) | const |
Definition at line 1651 of file qaction.cpp.
Referenced by QMenu::initStyleOption(), and QMenuPrivate::QMacMenuPrivate::syncAction().
bool QAction::isSeparator | ( | ) | const |
Returns true if this action is a separator action; otherwise it returns false.
Definition at line 839 of file qaction.cpp.
Referenced by QAccessibleMenu::actionText(), QAccessibleMenuBar::actionText(), QMenuPrivate::activateAction(), QMenuBarPrivate::QMacMenuBarPrivate::addAction(), QMenuBarPrivate::calcActionRects(), QAccessibleMenu::childAt(), QToolBarLayout::createItem(), QAxServerBase::createMenu(), QAxServerBase::createPopup(), QMenuPrivate::getLastVisibleAction(), QMenu::initStyleOption(), QMenu::isEmpty(), QMenu::keyPressEvent(), QMenu::mouseMoveEvent(), qt_mac_menu_event(), qt_mac_menu_merge_action(), qt_wce_insert_action(), QAccessibleMenu::role(), QAccessibleMenuBar::role(), QAccessibleMenuItem::role(), QMenuPrivate::scrollMenu(), QMenuPrivate::setCurrentAction(), QMenuPrivate::setFirstActionActive(), QMenuPrivate::setSyncAction(), QAccessibleMenu::state(), QAccessibleMenuBar::state(), QAccessibleMenuItem::state(), QMenuPrivate::QMacMenuPrivate::syncAction(), and QMenuPrivate::updateActionRects().
bool QAction::isVisible | ( | ) | const |
Definition at line 1246 of file qaction.cpp.
Referenced by actualMenuItemVisibility(), QSoftKeyManager::appendSoftkeys(), QMenuBarPrivate::calcActionRects(), QMenuPrivate::getLastVisibleAction(), QToolBarItem::isEmpty(), QMenu::isEmpty(), QMenuBarPrivate::macUpdateMenuBarImmediatly(), qt_mac_menu_event(), qt_wce_insert_action(), QAccessibleMenuItem::state(), QMenuPrivate::QMacMenuPrivate::syncAction(), and QMenuPrivate::updateActionRects().
QMenu * QAction::menu | ( | ) | const |
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.
Definition at line 793 of file qaction.cpp.
Referenced by QMenuBarPrivate::_q_internalShortcutActivated(), QAccessibleMenu::actionText(), QAccessibleMenuBar::actionText(), QAccessibleMenuItem::actionText(), actualMenuItemVisibility(), QAccessibleMenuItem::childCount(), QAxServerBase::createMenu(), QAxServerBase::createPopup(), QAccessibleMenu::doAction(), QAccessibleMenuBar::doAction(), QAccessibleMenuItem::doAction(), QToolButtonPrivate::hasMenu(), QAccessibleMenuItem::indexOfChild(), QMenuPrivate::init(), QMenu::initStyleOption(), QMenu::keyPressEvent(), QMenuBar::mouseReleaseEvent(), QMenu::mouseReleaseEvent(), QAxClientSite::OnPosRectChange(), QMenuBarPrivate::popupAction(), QMenuPrivate::popupAction(), QToolButtonPrivate::popupTimerDone(), qt_mac_menu_merge_action(), qt_wce_get_quit_action(), qt_wce_insert_action(), QMenuBarPrivate::QWceMenuBarPrivate::rebuild(), QAccessibleMenuItem::rect(), QDecoration::region(), QMenuPrivate::setCurrentAction(), QToolButton::setDefaultAction(), setMenu(), QMenuBar::setNativeMenuBar(), QMenu::setSeparatorsCollapsible(), QMenuPrivate::setSyncAction(), QAccessibleMenuItem::state(), QMenuBarPrivate::QMacMenuBarPrivate::syncAction(), QMenuPrivate::QMacMenuPrivate::syncAction(), QAccessibleMenuItem::text(), QMenuPrivate::wceCommands(), and QMenuBarPrivate::wceEmitSignals().
MenuRole QAction::menuRole | ( | ) | const |
Referenced by setMenuRole().
QWidget * QAction::parentWidget | ( | ) | const |
Returns the parent widget.
Definition at line 399 of file qaction.cpp.
Referenced by QSoftKeyManager::sendKeyEvent().
Priority QAction::priority | ( | ) | const |
Referenced by setPriority().
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 728 of file qaction.cpp.
void QAction::setAutoRepeat | ( | bool | on | ) |
Definition at line 589 of file qaction.cpp.
void QAction::setCheckable | ( | bool | b | ) |
Definition at line 1094 of file qaction.cpp.
Referenced by QFileDialogPrivate::createMenuActions(), QMdiSubWindowPrivate::createSystemMenu(), QFileDialogPrivate::createWidgets(), QmlJSDebugger::QmlToolBar::QmlToolBar(), QMultiInputContext::QMultiInputContext(), QWhatsThis::QWhatsThis(), and QWhatsThisAction::QWhatsThisAction().
|
slot |
Definition at line 1138 of file qaction.cpp.
Referenced by QActionGroupPrivate::_q_actionChanged(), activate(), QmlJSDebugger::QmlToolBar::activateColorPickerOnClick(), QmlJSDebugger::QmlToolBar::activateMarqueeSelectToolOnClick(), QmlJSDebugger::QmlToolBar::activateSelectToolOnClick(), QmlJSDebugger::QmlToolBar::activateZoomOnClick(), QFileDialogPrivate::createWidgets(), QWorkspacePrivate::init(), QmlJSDebugger::QmlToolBar::QmlToolBar(), QMultiInputContext::QMultiInputContext(), QFileDialog::restoreState(), QmlJSDebugger::QmlToolBar::setAnimationSpeed(), QmlJSDebugger::QmlToolBar::setDesignModeBehavior(), QPrintPreviewDialogPrivate::setFitting(), toggle(), and QWhatsThisPrivate::~QWhatsThisPrivate().
void QAction::setData | ( | const QVariant & | userData | ) |
Sets the action's internal data to the given userData.
Definition at line 1297 of file qaction.cpp.
Referenced by QmlJSDebugger::LiveSelectionTool::createContextMenu(), QCalendarWidgetPrivate::createNavigationBar(), QmlJSDebugger::QmlToolBar::QmlToolBar(), and QMultiInputContext::QMultiInputContext().
|
inlineslot |
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.
Definition at line 223 of file qaction.h.
Referenced by QDecoration::buildSysMenu().
|
slot |
Definition at line 1192 of file qaction.cpp.
Referenced by QScriptDebuggerPrivate::_q_onFindCodeRequest(), QFileDialogPrivate::_q_showContextMenu(), QActionGroup::addAction(), QDecoration::buildSysMenu(), QAbstractSpinBox::contextMenuEvent(), QFileDialogPrivate::createMenuActions(), QUndoGroup::createRedoAction(), QUndoStack::createRedoAction(), QTextControl::createStandardContextMenu(), QLineEdit::createStandardContextMenu(), QMdiSubWindowPrivate::createSystemMenu(), QUndoGroup::createUndoAction(), QUndoStack::createUndoAction(), QScriptDebuggerPrivate::handleResponse(), QmlJSDebugger::QmlToolBar::setDesignModeBehaviorOnClick(), QMdiSubWindowPrivate::setEnabled(), QSidebar::showContextMenu(), QScriptDebuggerPrivate::startInteraction(), and QMenuPrivate::QMacMenuPrivate::syncAction().
void QAction::setFont | ( | const QFont & | font | ) |
Definition at line 623 of file qaction.cpp.
Referenced by QmlJSDebugger::LiveSelectionTool::createContextMenu().
void QAction::setIcon | ( | const QIcon & | icon | ) |
Definition at line 772 of file qaction.cpp.
Referenced by QMdiSubWindowPrivate::createSystemMenu(), QMenuBar::defaultAction(), menuItemEntry(), qt_setupActionIcon(), QWhatsThis::QWhatsThis(), QWhatsThisAction::QWhatsThisAction(), QMenu::setSeparatorsCollapsible(), and QmlJSDebugger::QmlToolBar::updatePlayAction().
void QAction::setIconText | ( | const QString & | text | ) |
Definition at line 907 of file qaction.cpp.
void QAction::setIconVisibleInMenu | ( | bool | visible | ) |
Definition at line 1636 of file qaction.cpp.
void QAction::setMenu | ( | QMenu * | menu | ) |
Sets the menu contained by this action to the specified menu.
Definition at line 802 of file qaction.cpp.
Referenced by QmlJSDebugger::QmlToolBar::QmlToolBar().
void QAction::setMenuRole | ( | MenuRole | menuRole | ) |
Definition at line 1569 of file qaction.cpp.
void QAction::setPriority | ( | Priority | priority | ) |
Definition at line 1056 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 823 of file qaction.cpp.
Referenced by QMenuBar::addSeparator(), QMenu::addSeparator(), QToolBar::addSeparator(), QMenuBar::defaultAction(), QMenuBar::insertSeparator(), QMenu::insertSeparator(), QToolBar::insertSeparator(), QMultiInputContext::QMultiInputContext(), and QMenu::setSeparatorsCollapsible().
void QAction::setShortcut | ( | const QKeySequence & | shortcut | ) |
Definition at line 450 of file qaction.cpp.
Referenced by QMenu::addAction(), QmlJSDebugger::LiveSelectionTool::createContextMenu(), QFileDialogPrivate::createMenuActions(), QMenuBar::defaultAction(), menuItemEntry(), QWhatsThisAction::QWhatsThisAction(), setFont(), QMenu::setSeparatorsCollapsible(), and QmlJSDebugger::ZoomTool::ZoomTool().
void QAction::setShortcutContext | ( | Qt::ShortcutContext | context | ) |
Definition at line 558 of file qaction.cpp.
void QAction::setShortcuts | ( | const QList< QKeySequence > & | shortcuts | ) |
Sets shortcuts as the list of shortcuts that trigger the action.
The first element of the list is the primary shortcut.
Definition at line 474 of file qaction.cpp.
Referenced by QMdiSubWindowPrivate::createSystemMenu(), and setShortcuts().
void QAction::setShortcuts | ( | QKeySequence::StandardKey | key | ) |
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.
Definition at line 509 of file qaction.cpp.
void QAction::setSoftKeyRole | ( | SoftKeyRole | softKeyRole | ) |
Definition at line 1599 of file qaction.cpp.
Referenced by QDialogButtonBoxPrivate::addButton(), QSoftKeyManager::createAction(), and QWizardPrivate::ensureButton().
void QAction::setStatusTip | ( | const QString & | statusTip | ) |
Definition at line 974 of file qaction.cpp.
void QAction::setText | ( | const QString & | text | ) |
Definition at line 860 of file qaction.cpp.
Referenced by QMenuBar::defaultAction(), QFileDialogPrivate::retranslateStrings(), QDialogButtonBoxPrivate::retranslateStrings(), QUndoAction::setPrefixedText(), and QMenu::setSeparatorsCollapsible().
void QAction::setToolTip | ( | const QString & | tip | ) |
Definition at line 939 of file qaction.cpp.
|
slot |
Definition at line 1230 of file qaction.cpp.
Referenced by QActionGroup::addAction(), QSoftKeyManager::createAction(), QAxClientSite::qt_metacall(), QWidgetAction::setDefaultWidget(), and QMdiSubWindowPrivate::setVisible().
void QAction::setWhatsThis | ( | const QString & | what | ) |
Definition at line 1003 of file qaction.cpp.
QKeySequence QAction::shortcut | ( | ) | const |
Referenced by setFont(), setShortcut(), and setShortcuts().
Qt::ShortcutContext QAction::shortcutContext | ( | ) | const |
Referenced by setShortcutContext().
QList< QKeySequence > QAction::shortcuts | ( | ) | const |
Returns the list of shortcuts, with the primary shortcut as the first element of the list.
Definition at line 537 of file qaction.cpp.
Referenced by setShortcuts().
bool QAction::showStatusText | ( | QWidget * | widget = 0 | ) |
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.
Definition at line 1315 of file qaction.cpp.
Referenced by QMenuBarPrivate::activateAction(), QMenuPrivate::activateAction(), qt_mac_activate_action(), and QMenuPrivate::setCurrentAction().
SoftKeyRole QAction::softKeyRole | ( | ) | const |
Referenced by setSoftKeyRole().
QString QAction::statusTip | ( | ) | const |
Referenced by setStatusTip(), and showStatusText().
QString QAction::text | ( | ) | const |
Referenced by QAction(), setFont(), setIconText(), and setText().
|
slot |
This is a convenience function for the checked property.
Connect to it to change the checked state to its opposite state.
Definition at line 1120 of file qaction.cpp.
|
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.
checked is true if the action is checked, or false if the action is unchecked.
Referenced by QWhatsThis::QWhatsThis(), and setChecked().
QString QAction::toolTip | ( | ) | const |
Referenced by setToolTip().
|
inlineslot |
This is a convenience slot that calls activate(Trigger).
Definition at line 218 of file qaction.h.
Referenced by QAccessibleMenuItem::doAction().
|
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.
Referenced by activate(), and QWhatsThisAction::QWhatsThisAction().
QString QAction::whatsThis | ( | ) | const |
Referenced by setWhatsThis().
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
Definition at line 248 of file qaction.h.
Referenced by QWhatsThis::QWhatsThis().
|
private |
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.
Definition at line 85 of file qaction.h.
Referenced by QToolButtonPrivate::popupTimerDone().
|
private |
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.
|
private |
|
private |
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).
|
private |
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.
Definition at line 81 of file qaction.h.
Referenced by QmlJSDebugger::LiveSelectionTool::createContextMenu(), QMenu::initStyleOption(), QToolButton::setDefaultAction(), and QMenuPrivate::QMacMenuPrivate::syncAction().
|
private |
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.
On Symbian the icons which are passed to softkeys, i.e. to actions with softkey role, need to have pixmap alpha channel correctly set otherwise drawing artifacts will appear when softkey is pressed down.
If a null icon (QIcon::isNull() is passed into this function, the icon of the action is cleared.
Definition at line 75 of file qaction.h.
Referenced by QMenuBarPrivate::calcActionRects(), QMenuBar::initStyleOption(), QMenu::initStyleOption(), QToolButton::setDefaultAction(), QMenuPrivate::QMacMenuPrivate::syncAction(), and QMenuPrivate::updateActionRects().
|
private |
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 77 of file qaction.h.
Referenced by qt_wce_insert_action(), QToolButton::setDefaultAction(), and QNSOpenSavePanelDelegate::strip:.
|
private |
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:
|
private |
the action's menu role
This indicates what role the action serves in the application menu on Mac OS X. By default all action 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 Mac OS X (usually just before the first application window is shown).
Definition at line 88 of file qaction.h.
Referenced by qt_mac_menu_merge_accel(), qt_mac_menu_merge_action(), qt_mac_menu_merge_text(), qt_wce_get_quit_action(), QMenuPrivate::QMacMenuPrivate::syncAction(), and QMacMenuAction::~QMacMenuAction().
|
private |
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.
|
private |
the action's primary shortcut key
Returns the primary shortcut.
Valid keycodes for this property can be found in Qt::Key and Qt::Modifier . There is no default shortcut key.
Definition at line 83 of file qaction.h.
Referenced by QAccessibleWidget::actionText(), QMenu::initStyleOption(), QAccessibleMenuItem::keyBindings(), qt_mac_menu_event(), qt_mac_menu_merge_accel(), QMenuPrivate::QMacMenuPrivate::syncAction(), QAccessibleMenu::text(), QAccessibleMenuItem::text(), and QMenuPrivate::updateActionRects().
|
private |
the context for the action's shortcut
Valid values for this property can be found in Qt::ShortcutContext . The default value is Qt::WindowShortcut.
|
private |
the action's softkey role
This indicates what type of role this action describes in the softkey framework on platforms where such a framework is supported. Currently this is only supported on the Symbian platform.
The softkey role can be changed any time.
Definition at line 89 of file qaction.h.
Referenced by QSoftKeyManager::appendSoftkeys().
|
private |
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 79 of file qaction.h.
Referenced by QToolButton::setDefaultAction().
|
private |
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.
Definition at line 76 of file qaction.h.
Referenced by QCalendarWidgetPrivate::_q_monthChanged(), QAccessibleWidget::actionText(), actualMenuItemVisibility(), QMenuBarPrivate::QMacMenuBarPrivate::addAction(), QMenuPrivate::QMacMenuPrivate::addAction(), QMenuBarPrivate::calcActionRects(), QAxServerBase::createMenu(), QAxServerBase::createPopup(), QMenuBar::initStyleOption(), QMenu::initStyleOption(), QMenuBar::keyPressEvent(), QMenu::keyPressEvent(), QAxClientSite::OnPosRectChange(), qt_mac_menu_merge_action(), qt_mac_menu_merge_text(), QMenuBarPrivate::QWceMenuBarPrivate::rebuild(), QMenuBarPrivate::QMacMenuBarPrivate::syncAction(), QMenuPrivate::QMacMenuPrivate::syncAction(), QAccessibleMenuItem::text(), QMenuPrivate::updateActionRects(), and QMenuBarPrivate::updateGeometries().
|
private |
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 78 of file qaction.h.
Referenced by QAccessibleWidget::actionText(), and QToolButton::setDefaultAction().
|
private |
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 87 of file qaction.h.
Referenced by setIconVisibleInMenu().
|
private |
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 80 of file qaction.h.
Referenced by QMenuPrivate::activateAction(), QToolButton::setDefaultAction(), and QAccessibleMenu::text().