The Q3Action 類提供可以齣現在菜單和工具欄中的抽象用戶界麵動作。 更多...
| 頭: | #include <Q3Action> |
| 繼承: | QObject |
| 繼承者: | Q3ActionGroup |
|
| Q3Action (QObject * parent , const char * name = 0) | |
| Q3Action (const QString & menuText , QKeySequence accel , QObject * parent , const char * name = 0) | |
| Q3Action (const QIcon & icon , const QString & menuText , QKeySequence accel , QObject * parent , const char * name = 0) | |
| Q3Action (const QString & text , const QIcon & icon , const QString & menuText , QKeySequence accel , QObject * parent , const char * name = 0, bool toggle = false) | |
| Q3Action (const QString & text , const QString & menuText , QKeySequence accel , QObject * parent , const char * name = 0, bool toggle = false) | |
| Q3Action (QObject * parent , const char * name , bool toggle ) | |
| ~Q3Action () | |
| QKeySequence | accel () const |
| virtual bool | addTo (QWidget * w ) |
| QIcon | iconSet () const |
| bool | isEnabled () const |
| bool | isOn () const |
| bool | isToggleAction () const |
| bool | isVisible () const |
| QString | menuText () const |
| virtual bool | removeFrom (QWidget * w ) |
| virtual void | setAccel (const QKeySequence & key ) |
| virtual void | setIconSet (const QIcon &) |
| virtual void | setMenuText (const QString &) |
| virtual void | setStatusTip (const QString &) |
| virtual void | setText (const QString &) |
| virtual void | setToggleAction (bool) |
| virtual void | setToolTip (const QString &) |
| virtual void | setWhatsThis (const QString &) |
| QString | statusTip () const |
| QString | text () const |
| QString | toolTip () const |
| QString | whatsThis () const |
| void | activate () |
| void | setDisabled (bool disable ) |
| virtual void | setEnabled (bool) |
| virtual void | setOn (bool) |
| virtual void | setVisible (bool) |
| void | toggle () |
| void | activated () |
| void | toggled (bool on ) |
| virtual void | addedTo (QWidget * actionWidget , QWidget * container ) |
| virtual void | addedTo (int index , Q3PopupMenu * menu ) |
The Q3Action 類提供可以齣現在菜單和工具欄中的抽象用戶界麵動作。
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 action . 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 Q3Action may contain an icon, a menu text, an accelerator, a status text, a "What's 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 () 和 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 () 返迴 false。
Actions are added to widgets (menus or toolbars) using addTo (), and removed using removeFrom (). Note that when using Q3ToolBar and Q3PopupMenu , their actions must be Q3Actions.
一旦 Q3Action has been created it should be added to the relevant menu and toolbar and then connected to the slot which will perform the action.
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.
To prevent recursion, don't create an action as a child of a widget that the action is later added to.
This property holds the action's accelerator key.
The keycodes can be found in Qt::Key and Qt::Modifier . There is no default accelerator key.
訪問函數:
| QKeySequence | accel () const |
| virtual void | setAccel (const QKeySequence & key ) |
This property holds whether the action is enabled.
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.
What's this? help on disabled actions is still available provided the Q3Action::whatsThis 特性有設置。
訪問函數:
| bool | isEnabled () const |
| virtual void | setEnabled (bool) |
此特性保持動作的圖標。
The icon is used as the tool button icon and in the menu to the left of the menu text. There is no default icon.
若 null 圖標 ( QIcon::isNull () is passed into this function, the icon of the action is cleared.
(See the action/toggleaction/toggleaction.cpp example.)
訪問函數:
| QIcon | iconSet () const |
| virtual void | setIconSet (const QIcon &) |
此特性保持動作的菜單文本。
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.
訪問函數:
| QString | menuText () const |
| virtual void | setMenuText (const QString &) |
另請參閱 text .
This property holds whether a toggle action is on.
This property is always on (true) for command actions and Q3ActionGroup s; setOn() has no effect on them. For action's where isToggleAction () is true, this property's default value is off (false).
訪問函數:
| bool | isOn () const |
| virtual void | setOn (bool) |
另請參閱 toggleAction .
This property holds the action's status tip.
The statusTip is displayed on all status bars that this action's top-level parent widget provides.
If no status tip is defined, the action uses the tool tip text.
There is no default statusTip text.
訪問函數:
| QString | statusTip () const |
| virtual void | setStatusTip (const QString &) |
另請參閱 setToolTip ().
This property holds the action's descriptive text.
訪問函數:
| QString | text () const |
| virtual void | setText (const QString &) |
另請參閱 setMenuText (), setToolTip (),和 setStatusTip ().
This property holds whether the action is a toggle action.
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.
在某些情況下,1 個觸發操作的狀態應該從屬其它狀態 (例如:左對齊、居中和右對齊觸發動作,是相互排斥的)。要達成獨占觸發,把相關觸發動作添加到 Q3ActionGroup 采用 Q3ActionGroup::exclusive 特性被設為 true。
訪問函數:
| bool | isToggleAction () const |
| virtual void | setToggleAction (bool) |
This property holds the action's tool tip.
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.
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.
There is no default tool tip text.
訪問函數:
| QString | toolTip () const |
| virtual void | setToolTip (const QString &) |
另請參閱 setStatusTip () 和 setAccel ().
This property holds whether the action can be seen (e.g. in menus and toolbars).
若 visible 為 true,動作可見 (如:在菜單和工具欄) 並由用戶選取;若 visible 為 false,動作不可見 (或由用戶選取)。
不可見動作 not 變灰;它們根本不齣現。
訪問函數:
| bool | isVisible () const |
| virtual void | setVisible (bool) |
This property holds the action's "What's This?" help text.
The whats this text is used to provide a brief description of the action. The text may contain rich text (HTML-like tags -- see QStyleSheet for the list of supported tags). There is no default "What's This?" text.
訪問函數:
| QString | whatsThis () const |
| virtual void | setWhatsThis (const QString &) |
另請參閱 QWhatsThis .
構造動作稱為 name 采用父級 parent .
若 parent 是 Q3ActionGroup , the new action inserts itself into parent .
For accelerators and status tips to work, parent must either be a widget, or an action group whose parent is a widget.
警告: To prevent recursion, don't create an action as a child of a widget that the action is later added to.
This constructor results in an icon-less action with the menu text menuText and keyboard accelerator accel . It is a child of parent and called name .
若 parent 是 Q3ActionGroup , the action automatically becomes a member of it.
For accelerators and status tips to work, parent must either be a widget, or an action group whose parent is a widget.
動作使用刪減版的 menuText (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 and accel will be used for tool tips and status tips unless you provide text for these using setToolTip () 和 setStatusTip ().
調用 setToggleAction (true) to make the action a toggle action.
警告: 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 icon icon , the menu text menuText and keyboard accelerator accel . It is a child of parent and called name .
若 parent 是 Q3ActionGroup , the action automatically becomes a member of it.
For accelerators and status tips to work, parent must either be a widget, or an action group whose parent is a widget.
動作使用刪減版的 menuText (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 and accel will be used for tool tips and status tips unless you provide text for these using setToolTip () 和 setStatusTip ().
調用 setToggleAction (true) to make the action a toggle action.
警告: 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 description text , the icon or icon icon , the menu text menuText and keyboard accelerator accel . It is a child of parent and called name 。若 toggle is true the action will be a toggle action, otherwise it will be a command action.
若 parent 是 Q3ActionGroup , the action automatically becomes a member of it.
For accelerators and status tips to work, parent must either be a widget, or an action group whose parent is a widget.
The text and accel will be used for tool tips and status tips unless you provide specific text for these using setToolTip () 和 setStatusTip ().
This constructor results in an icon-less action with the description text , the menu text menuText and the keyboard accelerator accel . Its parent is parent and it is called name 。若 toggle is true the action will be a toggle action, otherwise it will be a command action.
The action automatically becomes a member of parent if parent 是 Q3ActionGroup .
For accelerators and status tips to work, parent must either be a widget, or an action group whose parent is a widget.
The text and accel will be used for tool tips and status tips unless you provide specific text for these using setToolTip () 和 setStatusTip ().
構造動作稱為 name 采用父級 parent .
若 toggle is true the action will be a toggle action, otherwise it will be a command action.
若 parent 是 Q3ActionGroup , the new action inserts itself into parent .
For accelerators and status tips to work, parent must either be a widget, or an action group whose parent is a widget.
銷毀對象並釋放分配的資源。
[slot]
void
Q3Action::
activate
()
Activates the action and executes all connected slots. This only works for actions that are not toggle actions.
另請參閱 toggle ().
[signal]
void
Q3Action::
activated
()
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.
Connect to this signal for command actions. Connect to the toggled () signal for toggle actions.
[虛擬]
bool
Q3Action::
addTo
(
QWidget
*
w
)
Adds this action to widget w .
Currently actions may be added to Q3ToolBar and Q3PopupMenu widgets.
An action added to a tool bar is automatically displayed as a tool button; an action added to a pop up menu appears as a menu option.
addTo() returns true if the action was added successfully and false otherwise. (If w 不是 Q3ToolBar or Q3PopupMenu the action will not be added and false will be returned.)
另請參閱 removeFrom ().
[virtual protected]
void
Q3Action::
addedTo
(
QWidget
*
actionWidget
,
QWidget
*
container
)
此函數的調用是從 addTo () function when it has created a widget ( actionWidget ) for the action in the container .
[virtual protected]
void
Q3Action::
addedTo
(
int
index
,
Q3PopupMenu
*
menu
)
這是重載函數。
此函數的調用是從 addTo () function when it has created a menu item at the index position index in the popup menu menu .
[虛擬]
bool
Q3Action::
removeFrom
(
QWidget
*
w
)
Removes the action from widget w .
Returns true if the action was removed successfully; otherwise returns false.
另請參閱 addTo ().
[slot]
void
Q3Action::
setDisabled
(
bool
disable
)
Disables the action if disable is true; otherwise enables the action.
見 enabled 文檔編製,瞭解更多信息。
[slot]
void
Q3Action::
toggle
()
Toggles the state of a toggle action.
另請參閱 on , activate (), toggled (),和 isToggleAction ().
[signal]
void
Q3Action::
toggled
(
bool
on
)
This signal is emitted when a toggle action changes state; command actions and Q3ActionGroup s don't emit toggled().
The on argument denotes the new state: If on is true the toggle action is switched on, and if on is false the toggle action is switched off.
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.
另請參閱 activated (), setToggleAction (),和 setOn ().