In GUI applications many commands can be invoked via a menu option, a toolbar button and a keyboard accelerator. Since the same action must be performed regardless of how the action was invoked, and since the menu and toolbar should be kept in sync, it is useful to represent a command as an \fIaction\fR. An action can be added to a menu and a toolbar and will automatically keep them in sync. For example, if the user presses a Bold toolbar button the Bold menu item will automatically be checked.
A TQAction may contain an icon, a menu text, an accelerator, a status text, a whats this text and a tool tip. Most of these can be set in the constructor. They can also be set independently with setIconSet(), setText(), setMenuText(), setToolTip(), setStatusTip(), setWhatsThis() and setAccel().
An action may be a toggle action e.g. a Bold toolbar button, or a command action, e.g. 'Open File' to invoke an open file dialog. Toggle actions emit the toggled() signal when their state changes. Both command and toggle actions emit the activated() signal when they are invoked. Use setToggleAction() to set an action's toggled status. To see if an action is a toggle action use isToggleAction(). A toggle action may be "on", isOn() returns TRUE, or "off", isOn() returns FALSE.
.PP
Actions are added to widgets (menus or toolbars) using addTo(), and removed using removeFrom().
Once a TQAction has been created it should be added to the relevant menu and toolbar and then connected to the slot which will perform the action. For example:
We create a "File Save" action with a menu text of "&Save" and \fICtrl+S\fR as the keyboard accelerator. We connect the fileSaveAction's activated() signal to our own save() slot. Note that at this point there is no menu or toolbar action, we'll add them next:
We create a toolbar and add our fileSaveAction to it. Similarly we create a menu, add a top-level menu item, and add our fileSaveAction.
.PP
We recommend that actions are created as children of the window that they are used in. In most cases actions will be children of the application's main window.
.PP
To prevent recursion, don't create an action as a child of a widget that the action is later added to.
.PP
See also Main Window and Related Classes and Basic Widgets.
This constructor results in an icon-less action with the the menu text \fImenuText\fR and keyboard accelerator \fIaccel\fR. It is a child of \fIparent\fR and called \fIname\fR.
For accelerators and status tips to work, \fIparent\fR must either be a widget, or an action group whose parent is a widget.
.PP
The action uses a stripped version of \fImenuText\fR (e.g. "&Menu Option..." becomes "Menu Option") as descriptive text for toolbuttons. You can override this by setting a specific description with setText(). The same text and \fIaccel\fR will be used for tool tips and status tips unless you provide text for these using setToolTip() and setStatusTip().
.PP
Call setToggleAction(TRUE) to make the action a toggle action.
.PP
\fBWarning:\fR To prevent recursion, don't create an action as a child of a widget that the action is later added to.
This constructor creates an action with the following properties: the icon or iconset \fIicon\fR, the menu text \fImenuText\fR and keyboard accelerator \fIaccel\fR. It is a child of \fIparent\fR and called \fIname\fR.
For accelerators and status tips to work, \fIparent\fR must either be a widget, or an action group whose parent is a widget.
.PP
The action uses a stripped version of \fImenuText\fR (e.g. "&Menu Option..." becomes "Menu Option") as descriptive text for toolbuttons. You can override this by setting a specific description with setText(). The same text and \fIaccel\fR will be used for tool tips and status tips unless you provide text for these using setToolTip() and setStatusTip().
.PP
Call setToggleAction(TRUE) to make the action a toggle action.
.PP
\fBWarning:\fR To prevent recursion, don't create an action as a child of a widget that the action is later added to.
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
This constructor creates an action with the following properties: the description \fItext\fR, the icon or iconset \fIicon\fR, the menu text \fImenuText\fR and keyboard accelerator \fIaccel\fR. It is a child of \fIparent\fR and called \fIname\fR. If \fItoggle\fR is TRUE the action will be a toggle action, otherwise it will be a command action.
For accelerators and status tips to work, \fIparent\fR must either be a widget, or an action group whose parent is a widget.
.PP
The \fItext\fR and \fIaccel\fR will be used for tool tips and status tips unless you provide specific text for these using setToolTip() and setStatusTip().
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
This constructor results in an icon-less action with the description \fItext\fR, the menu text \fImenuText\fR and the keyboard accelerator \fIaccel\fR. Its parent is \fIparent\fR and it is called \fIname\fR. If \fItoggle\fR is TRUE the action will be a toggle action, otherwise it will be a command action.
For accelerators and status tips to work, \fIparent\fR must either be a widget, or an action group whose parent is a widget.
.PP
The \fItext\fR and \fIaccel\fR will be used for tool tips and status tips unless you provide specific text for these using setToolTip() and setStatusTip().
This signal is emitted when an action is activated by the user, e.g. when the user clicks a menu option or a toolbar button or presses an action's accelerator key combination.
.PP
Connect to this signal for command actions. Connect to the toggled() signal for toggle actions.
.PP
Examples:
.)l action/application.cpp, chart/chartform.cpp, and themes/themes.cpp.
addTo() returns TRUE if the action was added successfully and FALSE otherwise. (If \fIw\fR is not a TQToolBar or TQPopupMenu the action will not be added and FALSE will be returned.)
The \fIon\fR argument denotes the new state: If \fIon\fR is TRUE the toggle action is switched on, and if \fIon\fR is FALSE the toggle action is switched off.
.PP
To trigger a user command depending on whether a toggle action has been switched on or off connect it to a slot that takes a bool to indicate the state, e.g.
Set this property's value with setAccel() and get this property's value with accel().
.SH "bool enabled"
This property holds whether the action is enabled.
.PP
Disabled actions can't be chosen by the user. They don't disappear from the menu/tool bar but are displayed in a way which indicates that they are unavailable, e.g. they might be displayed grayed out.
If the action is added to a menu the menu option will consist of the icon (if there is one), the menu text and the accelerator (if there is one). If the menu text is not explicitly set in the constructor or by using setMenuText() the action's description text will be used as the menu text. There is no default menu text.
.PP
See also text.
.PP
Set this property's value with setMenuText() and get this property's value with menuText().
.SH "bool on"
This property holds whether a toggle action is on.
This property is always on (TRUE) for command actions and TQActionGroups; setOn() has no effect on them. For action's where isToggleAction() is TRUE, this property's default value is off (FALSE).
If TQMainWindow::usesTextLabel is TRUE, the text appears as a label in the relevant tool button. It also serves as the default text in menus and tool tips if these have not been specifically defined. There is no default text.
Set this property's value with setText() and get this property's value with text().
.SH "bool toggleAction"
This property holds whether the action is a toggle action.
.PP
A toggle action is one which has an on/off state. For example a Bold toolbar button is 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. This property's default 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 TQActionGroup with the TQActionGroup::exclusive property set to TRUE.
This text is used for the tool tip. If no status tip has been set the tool tip will be used for the status tip.
.PP
If no tool tip is specified the action's text is used, and if that hasn't been specified the description text is used as the tool tip text.
.PP
There is no default tool tip text.
.PP
See also statusTip and accel.
.PP
Set this property's value with setToolTip() and get this property's value with toolTip().
.SH "bool visible"
This property holds whether the action can be seen (e.g. in menus and toolbars).
.PP
If \fIvisible\fR is TRUE the action can be seen (e.g. in menus and toolbars) and chosen by the user; if \fIvisible\fR is FALSE the action cannot be seen or chosen by the user.
.PP
Actions which are not visible are \fInot\fR grayed out; they do not appear at all.
.PP
Set this property's value with setVisible() and get this property's value with isVisible().
The whats this text is used to provide a brief description of the action. The text may contain rich text (HTML-like tags -- see TQStyleSheet for the list of supported tags). There is no default" What's This" text.