Q3Action Class Reference
|
|
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 class provides an abstract user interface action that can appear both in menus and tool bars.
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. Большинство из них могут быть установлены в конструкторе. 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.
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.
Once a 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. В большинстве случаев действия будут дочерними элементами главного окна приложения.
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 ) |
Это свойство указывает, включено ли действие.
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.
Справка Что это? help on disabled actions is still available provided the Q3Action::whatsThis property is set.
Функции доступа:
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. По умолчанию пиктограммы нет.
Если в эту функцию передаётся нулевая пиктограмма (QIcon::isNull()), то пиктограмма действия очищается.
(See the action/toggleaction/toggleaction.cpp example.)
Функции доступа:
QIcon | iconSet () const |
virtual void | setIconSet ( const QIcon & ) |
This property holds the action's menu text.
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 Q3ActionGroups; 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.
Это свойство содержит подсказку строки состояния для действия.
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().
Это свойство содержит текст, описывающий действие.
Функции доступа:
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. Действие, которое не является переключаемым действием, является командным действием; командное действие просто выполняется, например, сохраняет файл. This property's default is false.
В некоторых ситуациях состояние одного переключаемого действия должно зависеть от состояний других. Например, переключаемые действия "Left Align", "Center" и "Right Align" являются взаимоисключающими. To achieve exclusive toggling, add the relevant toggle actions to a Q3ActionGroup with the Q3ActionGroup::exclusive property set to 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().
Это свойство указывает, можно ли будет увидеть действие (например, в меню и панелях инструментов).
Если visible равно true, то пользователь может увидеть (например, в меню и на панелях инструментов) и выбрать действие; если visible равно false, то пользователь не может увидеть и выбрать действие.
Действия, которые не видимы, не отображаются серым цветом; они вообще не появляются.
Функции доступа:
bool | isVisible () const |
virtual void | setVisible ( bool ) |
Это свойство содержит текст справки "Что это?" для действия.
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). По умолчанию текст "Что это?" отсутствует.
Функции доступа:
QString | whatsThis () const |
virtual void | setWhatsThis ( const QString & ) |
Смотрите также QWhatsThis.
Constructs an action called name with parent parent.
If parent is a 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.
Warning: 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.
If parent is a 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 action uses a stripped version of menuText (e.g. "&Menu Option..." becomes "Menu Option") as descriptive text for tool buttons. Вы можете изменить это, установив конкретное описание с помощью setText(). The same text and accel will be used for tool tips and status tips unless you provide text for these using setToolTip() and setStatusTip().
Call setToggleAction(true) to make the action a toggle action.
Warning: 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.
If parent is a 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 action uses a stripped version of menuText (e.g. "&Menu Option..." becomes "Menu Option") as descriptive text for tool buttons. Вы можете изменить это, установив конкретное описание с помощью setText(). The same text and accel will be used for tool tips and status tips unless you provide text for these using setToolTip() and setStatusTip().
Call setToggleAction(true) to make the action a toggle action.
Warning: 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. If toggle is true the action will be a toggle action, otherwise it will be a command action.
If parent is a 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() and 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. If 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 is a 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() and setStatusTip().
Constructs an action called name with parent parent.
If toggle is true the action will be a toggle action, otherwise it will be a command action.
If parent is a 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.
Удаляет объект и освобождает выделенные ему ресурсы.
Activates the action and executes all connected slots. This only works for actions that are not toggle actions.
Смотрите также toggle().
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 the toggled() signal for toggle actions.
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 is not a Q3ToolBar or Q3PopupMenu the action will not be added and false will be returned.)
Смотрите также removeFrom().
This function is called from the addTo() function when it has created a widget (actionWidget) for the action in the container.
Это перегруженная функция.
This function is called from the addTo() function when it has created a menu item at the index position index in the popup menu menu.
Removes the action from widget w.
Returns true if the action was removed successfully; otherwise returns false.
Смотрите также addTo().
Disables the action if disable is true; otherwise enables the action.
Для получения дополнительной информации смотрите документацию enabled.
Меняет состояние переключаемого действия.
Смотрите также on, activate(), toggled() и isToggleAction().
This signal is emitted when a toggle action changes state; command actions and Q3ActionGroups 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().
Авторские права © 2010 Nokia Corporation и/или её дочерние компании | Торговые марки | Qt 4.6.4 |
Попытка перевода Qt документации. Если есть желание присоединиться, или если есть замечания или пожелания, то заходите на форум: Перевод Qt документации на русский язык... Люди внесшие вклад в перевод: Команда переводчиков |