#include <qaction.h>
Inheritance diagram for QAction:


parent and widget are different parent does not define context
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().
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:
mainwindows/application/mainwindow.cpp openAct connect fileMenu->addAction(openAct fileMenu->addAction(openAct fileToolBar->addAction(openAct fileToolBar->addAction(openAct
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.
Definition at line 43 of file qaction.h.
Public Types | |
| enum | MenuRole |
| enum | ActionEvent |
Public Slots | |
| void | trigger () |
| void | hover () |
| void | setChecked (bool) |
| void | toggle () |
| void | setEnabled (bool) |
| void | setDisabled (bool b) |
| void | setVisible (bool) |
Signals | |
| void | changed () |
| void | triggered (bool checked=false) |
| void | hovered () |
| void | toggled (bool) |
Public Member Functions | |
| QAction (QObject *parent) | |
| QAction (const QString &text, QObject *parent) | |
| QAction (const QIcon &icon, const QString &text, QObject *parent) | |
| ~QAction () | |
| void | setActionGroup (QActionGroup *group) |
| QActionGroup * | actionGroup () const |
| 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 |
| QMenu * | menu () const |
| void | setMenu (QMenu *menu) |
| void | setSeparator (bool b) |
| bool | isSeparator () const |
| void | setShortcut (const QKeySequence &shortcut) |
| QKeySequence | shortcut () const |
| void | setShortcuts (const QList< QKeySequence > &shortcuts) |
| void | setShortcuts (QKeySequence::StandardKey) |
| QList< QKeySequence > | shortcuts () const |
| void | setShortcutContext (Qt::ShortcutContext context) |
| Qt::ShortcutContext | shortcutContext () const |
| void | setAutoRepeat (bool) |
| bool | autoRepeat () const |
| void | setFont (const QFont &font) |
| QFont | font () const |
| void | setCheckable (bool) |
| bool | isCheckable () const |
| QVariant | data () const |
| void | setData (const QVariant &var) |
| bool | isChecked () const |
| bool | isEnabled () const |
| bool | isVisible () const |
| void | activate (ActionEvent event) |
| bool | showStatusText (QWidget *widget=0) |
| void | setMenuRole (MenuRole menuRole) |
| MenuRole | menuRole () const |
| QWidget * | parentWidget () const |
| QList< QWidget * > | associatedWidgets () const |
Protected Member Functions | |
| bool | event (QEvent *) |
| QAction (QActionPrivate &dd, QObject *parent) | |
Friends | |
| class | QWidget |
| class | QActionGroup |
| class | QMenu |
| class | QMenuBar |
| class | QShortcutMap |
| class | QToolButton |
| enum QAction::MenuRole |
This enum describes how an action should be moved into the application menu on Mac OS X.
NoRole This action should not be put into the application menu TextHeuristicRole This action should be put in the application menu based on the action's text as described in the QMenuBar documentation. ApplicationSpecificRole This action should be put in the application menu with an application specific role AboutQtRole This action matches handles the "About Qt" menu item. AboutRole This action should be placed where the "About" menu item is in the application menu. PreferencesRole This action should be placed where the "Preferences..." menu item is in the application menu. QuitRole This action should be placed where the Quit menu item is in the application menu.
Definition at line 68 of file qaction.h.
00068 { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole, 00069 AboutRole, PreferencesRole, QuitRole };
| enum QAction::ActionEvent |
This enum type is used when calling QAction::activate()
Trigger this will cause the QAction::triggered() signal to be emitted.
Hover this will cause the QAction::hovered() signal to be emitted.
Definition at line 142 of file qaction.h.
| QAction::QAction | ( | QObject * | parent | ) | [explicit] |
Constructs an action with parent. If parent is an action group the action will be automatically inserted into the group.
Definition at line 227 of file qaction.cpp.
References d, and QObject::parent().
00228 : QObject(*(new QActionPrivate), parent) 00229 { 00230 Q_D(QAction); 00231 d->group = qobject_cast<QActionGroup *>(parent); 00232 if (d->group) 00233 d->group->addAction(this); 00234 }
Here is the call graph for this function:

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 toolbuttons. You can override this by setting a specific description with setText(). The same text will be used for tooltips unless you specify a different test using setToolTip().
Definition at line 250 of file qaction.cpp.
References d, QObject::parent(), and text().
00251 : QObject(*(new QActionPrivate), parent) 00252 { 00253 Q_D(QAction); 00254 d->text = text; 00255 d->group = qobject_cast<QActionGroup *>(parent); 00256 if (d->group) 00257 d->group->addAction(this); 00258 }
Here is the call graph for this function:

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 toolbuttons. You can override this by setting a specific description with setText(). The same text will be used for tooltips unless you specify a different test using setToolTip().
Definition at line 272 of file qaction.cpp.
References d, icon(), QObject::parent(), and text().
00273 : QObject(*(new QActionPrivate), parent) 00274 { 00275 Q_D(QAction); 00276 d->icon = icon; 00277 d->text = text; 00278 d->group = qobject_cast<QActionGroup *>(parent); 00279 if (d->group) 00280 d->group->addAction(this); 00281 }
Here is the call graph for this function:

| QAction::~QAction | ( | ) |
Destroys the object and frees allocated resources.
Definition at line 544 of file qaction.cpp.
00545 { 00546 Q_D(QAction); 00547 for (int i = d->widgets.size()-1; i >= 0; --i) { 00548 QWidget *w = d->widgets.at(i); 00549 w->removeAction(this); 00550 } 00551 if (d->group) 00552 d->group->removeAction(this); 00553 #ifndef QT_NO_SHORTCUT 00554 if (d->shortcutId && qApp) 00555 qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); 00556 #endif 00557 }
| QAction::QAction | ( | QActionPrivate & | dd, | |
| QObject * | parent | |||
| ) | [protected] |
| 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 567 of file qaction.cpp.
References QActionGroup::addAction(), and d.
Referenced by QToolBar::resizeEvent().
00568 { 00569 Q_D(QAction); 00570 if(group == d->group) 00571 return; 00572 00573 if(d->group) 00574 d->group->removeAction(this); 00575 d->group = group; 00576 if(group) 00577 group->addAction(this); 00578 }
Here is the call graph for this function:

| 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 586 of file qaction.cpp.
References d.
Referenced by QMenuPrivate::getStyleOption().
| void QAction::setIcon | ( | const QIcon & | icon | ) |
Definition at line 604 of file qaction.cpp.
Referenced by QWorkspacePrivate::_q_updateActions(), qdesigner_internal::ActionEditor::ActionEditor(), Q3ActionGroup::addTo(), QDesignerFormWindow::changeEvent(), QDesignerToolWindow::changeEvent(), TextEdit::colorChanged(), qdesigner_internal::createCheckableAction(), qdesigner_internal::SignalSlotEditorPlugin::initialize(), qdesigner_internal::BuddyEditorPlugin::initialize(), qdesigner_internal::TabOrderEditorPlugin::initialize(), QDesignerActions::QDesignerActions(), QWhatsThisAction::QWhatsThisAction(), MainWindow::setActionsEnabled(), QtWindowListMenu::setCascadeIcon(), QtWindowListMenu::setCloseAllIcon(), QtWindowListMenu::setCloseIcon(), QtWindowListMenu::setTileIcon(), MainWindow::setupGoActions(), and SpreadSheet::updateColor().
Here is the call graph for this function:

| QIcon QAction::icon | ( | ) | const |
Definition at line 611 of file qaction.cpp.
References d.
Referenced by qdesigner_internal::ActionEditor::createListWidgetItem(), qdesigner_internal::ActionEditor::editAction(), QMenuBarPrivate::getStyleOption(), QMenuPrivate::getStyleOption(), QDesignerWorkbench::initialize(), qdesigner_internal::ActionEditor::manageAction(), QAction(), setIcon(), qdesigner_internal::ActionEditor::slotActionChanged(), QDesignerMenuBar::startDrag(), QDesignerMenu::startDrag(), and QDesignerToolBar::startDrag().
| void QAction::setText | ( | const QString & | text | ) |
Definition at line 685 of file qaction.cpp.
Referenced by QWorkspacePrivate::_q_updateActions(), Q3ActionGroup::addTo(), qdesigner_internal::ButtonTaskMenu::ButtonTaskMenu(), QDesignerFormWindow::changeEvent(), QDesignerToolWindow::changeEvent(), qdesigner_internal::ComboBoxTaskMenu::ComboBoxTaskMenu(), qdesigner_internal::createCheckableAction(), QDockWidgetPrivate::init(), HelpDialog::initialize(), qdesigner_internal::LabelTaskMenu::LabelTaskMenu(), qdesigner_internal::LineEditTaskMenu::LineEditTaskMenu(), qdesigner_internal::ListWidgetTaskMenu::ListWidgetTaskMenu(), QDesignerMenuBar::QDesignerMenuBar(), QDesignerTabWidget::QDesignerTabWidget(), QDesignerToolBox::QDesignerToolBox(), QDesignerToolWindow::QDesignerToolWindow(), MainWindow::setActionsEnabled(), QUndoAction::setPrefixedText(), MainWindow::setup(), MainWindow::setupGoActions(), qdesigner_internal::TableWidgetTaskMenu::TableWidgetTaskMenu(), qdesigner_internal::TextEditTaskMenu::TextEditTaskMenu(), ToolBar::ToolBar(), qdesigner_internal::ToolBarTaskMenu::ToolBarTaskMenu(), qdesigner_internal::TreeWidgetTaskMenu::TreeWidgetTaskMenu(), and MainWindow::updateRecentFileActions().
00686 { 00687 Q_D(QAction); 00688 if (d->text == text) 00689 return; 00690 00691 d->text = text; 00692 d->sendDataChanged(); 00693 }
Here is the call graph for this function:

| QString QAction::text | ( | ) | const |
Definition at line 695 of file qaction.cpp.
Referenced by QCalendarWidgetPrivate::_q_monthChanged(), MainWindow::actionTriggered(), MainWindow::applyFilter(), MainWindow::changeBrush(), QDesignerFormWindow::closeEvent(), QDesignerMenu::createRealMenuAction(), qdesigner_internal::ActionEditor::editAction(), QMenuBarPrivate::getStyleOption(), QMenuPrivate::getStyleOption(), QDesignerWorkbench::initialize(), MainWindow::insertShape(), QMenu::keyPressEvent(), Q3TextEdit::pickSpecial(), QAction(), TrWindow::recentFileActivated(), setIconText(), QUndoAction::setPrefixedText(), setText(), QDesignerMenu::showLineEdit(), QDesignerMenuBar::showLineEdit(), ColorSwatch::splitInto(), ColorSwatch::tabInto(), and QMenuBarPrivate::updateGeometries().
00696 { 00697 Q_D(const QAction); 00698 QString s = d->text; 00699 if(s.isEmpty()) { 00700 s = d->iconText; 00701 s.replace(QLatin1Char('&'), QLatin1String("&&")); 00702 } 00703 return s; 00704 }
| void QAction::setIconText | ( | const QString & | text | ) |
| QString QAction::iconText | ( | ) | const |
Definition at line 739 of file qaction.cpp.
References d, and qt_strippedText().
00740 { 00741 Q_D(const QAction); 00742 if (d->iconText.isEmpty()) 00743 return qt_strippedText(d->text); 00744 return d->iconText; 00745 }
Here is the call graph for this function:

| void QAction::setToolTip | ( | const QString & | tip | ) |
| QString QAction::toolTip | ( | ) | const |
Definition at line 768 of file qaction.cpp.
References d, and qt_strippedText().
00769 { 00770 Q_D(const QAction); 00771 if (d->tooltip.isEmpty()) { 00772 if (!d->text.isEmpty()) 00773 return qt_strippedText(d->text); 00774 return d->iconText; 00775 } 00776 return d->tooltip; 00777 }
Here is the call graph for this function:

| void QAction::setStatusTip | ( | const QString & | statusTip | ) |
Definition at line 788 of file qaction.cpp.
References d.
Referenced by qdesigner_internal::FormWindowManager::setupActions().
00789 { 00790 Q_D(QAction); 00791 if (d->statustip == statustip) 00792 return; 00793 00794 d->statustip = statustip; 00795 d->sendDataChanged(); 00796 }
| QString QAction::statusTip | ( | ) | const |
| void QAction::setWhatsThis | ( | const QString & | what | ) |
Definition at line 814 of file qaction.cpp.
References d.
Referenced by qdesigner_internal::FormWindowManager::setupActions(), and MainWindow::setupGoActions().
00815 { 00816 Q_D(QAction); 00817 if (d->whatsthis == whatsthis) 00818 return; 00819 00820 d->whatsthis = whatsthis; 00821 d->sendDataChanged(); 00822 }
| QString QAction::whatsThis | ( | ) | const |
Definition at line 824 of file qaction.cpp.
References d.
Referenced by QMenuPrivate::activateAction(), and QAccessibleMenu::text().
| 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 625 of file qaction.cpp.
References d.
Referenced by Q3ActionGroup::addTo(), QDesignerMenuBar::adjustIndicator(), QDesignerMenuBar::checkAction(), QDesignerMenu::checkAction(), QAbstractFormBuilder::createActionRefDom(), qdesigner_internal::QDesignerResource::createDom(), QAbstractFormBuilder::createDom(), qdesigner_internal::ActionEditor::createListWidgetItem(), QDesignerMenu::createRealMenuAction(), QAccessibleMenu::doAction(), QAccessibleMenuBar::doAction(), QDesignerMenu::dropEvent(), QDesignerMenu::enterEditMode(), QDesignerMenu::findOrCreateSubMenu(), QMenuPrivate::getStyleOption(), QDesignerMenu::handleMouseMoveEvent(), QDesignerMenu::handleMousePressEvent(), QToolButtonPrivate::hasMenu(), QDesignerMenu::hasSubMenuPixmap(), QDesignerMenuBar::hideMenu(), qdesigner_internal::RemoveMenuActionCommand::init(), qdesigner_internal::AddMenuActionCommand::init(), QMenu::keyPressEvent(), QDesignerMenu::leaveEditMode(), qdesigner_internal::ActionEditor::manageAction(), qdesigner_internal::merge(), QMenu::mouseReleaseEvent(), QMenuBar::mouseReleaseEvent(), QDesignerMenuBar::paintEvent(), QMenuBarPrivate::popupAction(), QMenuPrivate::popupAction(), QToolButtonPrivate::popupTimerDone(), qdesigner_internal::AddMenuActionCommand::redo(), qdesigner_internal::RemoveMenuActionCommand::redo(), QDesignerMenu::removeRealMenu(), QMenuPrivate::setCurrentAction(), qdesigner_internal::ObjectInspector::setFormWindow(), setMenu(), QDesignerMenuBar::showMenu(), qdesigner_internal::ActionEditor::slotActionChanged(), qdesigner_internal::AddMenuActionCommand::undo(), qdesigner_internal::RemoveMenuActionCommand::undo(), and qdesigner_internal::ActionEditor::updatePropertyEditor().
| void QAction::setMenu | ( | QMenu * | menu | ) |
Sets the menu contained by this action to the specified menu.
Definition at line 634 of file qaction.cpp.
Referenced by Window::createPushButtonGroup(), QDesignerMenu::createRealMenuAction(), and QDesignerMenu::removeRealMenu().
Here is the call graph for this function:

| 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 651 of file qaction.cpp.
References d.
Referenced by QMenuBar::addSeparator(), QToolBar::addSeparator(), QMenu::addSeparator(), Q3Action::addTo(), qdesigner_internal::ButtonTaskMenu::ButtonTaskMenu(), qdesigner_internal::ComboBoxTaskMenu::ComboBoxTaskMenu(), qdesigner_internal::ContainerWidgetTaskMenu::ContainerWidgetTaskMenu(), QAbstractFormBuilder::create(), qdesigner_internal::QDesignerResource::create(), QDesignerMenu::createAction(), QDesignerToolBar::createAction(), SpreadSheet::createActions(), qdesigner_internal::FormWindow::finishContextMenu(), qdesigner_internal::GroupBoxTaskMenu::GroupBoxTaskMenu(), QMenu::insertSeparator(), QMenuBar::insertSeparator(), QToolBar::insertSeparator(), qdesigner_internal::LabelTaskMenu::LabelTaskMenu(), qdesigner_internal::LineEditTaskMenu::LineEditTaskMenu(), qdesigner_internal::ListWidgetTaskMenu::ListWidgetTaskMenu(), QDesignerActions::QDesignerActions(), qdesigner_internal::QDesignerTaskMenu::QDesignerTaskMenu(), QMultiInputContext::QMultiInputContext(), qdesigner_internal::SentinelAction::SentinelAction(), qdesigner_internal::TableWidgetTaskMenu::TableWidgetTaskMenu(), qdesigner_internal::TextEditTaskMenu::TextEditTaskMenu(), qdesigner_internal::ToolBarTaskMenu::ToolBarTaskMenu(), and qdesigner_internal::TreeWidgetTaskMenu::TreeWidgetTaskMenu().
00652 { 00653 Q_D(QAction); 00654 if (d->separator == b) 00655 return; 00656 00657 d->separator = b; 00658 d->sendDataChanged(); 00659 }
| bool QAction::isSeparator | ( | ) | const |
Returns true if this action is a separator action; otherwise it returns false.
Definition at line 667 of file qaction.cpp.
References d.
Referenced by QMenuPrivate::activateAction(), QDesignerWorkbench::changeBringToFrontVisiblity(), QAccessibleMenu::childAt(), QAbstractFormBuilder::createActionRefDom(), QAbstractFormBuilder::createDom(), QToolBarPrivate::createItem(), QMenuPrivate::filterActions(), QMenuPrivate::getStyleOption(), QDesignerMenu::hasSubMenuPixmap(), qdesigner_internal::ActionEditor::manageAction(), QAccessibleMenuBar::role(), QAccessibleMenu::role(), QMenuPrivate::setCurrentAction(), qdesigner_internal::ActionEditor::setFormWindow(), QDesignerMenu::showLineEdit(), QDesignerMenuBar::showLineEdit(), QDesignerMenu::showSubMenu(), QDesignerMenu::slotShowSubMenuNow(), QAccessibleMenu::state(), and QAccessibleMenuBar::state().
| void QAction::setShortcut | ( | const QKeySequence & | shortcut | ) |
Definition at line 326 of file qaction.cpp.
References d, qApp, and shortcut().
Referenced by QMenu::addAction(), ColorSwatch::ColorSwatch(), QPixelTool::contextMenuEvent(), ImageViewer::createActions(), MainWindow::createActions(), SpreadSheet::createActions(), qdesigner_internal::SignalSlotEditorPlugin::initialize(), Launcher::Launcher(), QDBusViewer::QDBusViewer(), QDesignerActions::QDesignerActions(), QDesignerPropertyEditor::QDesignerPropertyEditor(), QWhatsThisAction::QWhatsThisAction(), qdesigner_internal::RichTextEditorToolBar::RichTextEditorToolBar(), qdesigner_internal::FormWindowManager::setupActions(), MainWindow::setupMenus(), TextEdit::setupTextActions(), and SourceTextEdit::SourceTextEdit().
00327 { 00328 Q_D(QAction); 00329 if (d->shortcut == shortcut) 00330 return; 00331 00332 d->shortcut = shortcut; 00333 d->redoGrab(qApp->d_func()->shortcutMap); 00334 d->sendDataChanged(); 00335 }
Here is the call graph for this function:

| QKeySequence QAction::shortcut | ( | ) | const |
Returns the primary shortcut.
Definition at line 386 of file qaction.cpp.
References d.
Referenced by QMenuPrivate::getStyleOption(), setShortcut(), and QAccessibleMenu::text().
| void QAction::setShortcuts | ( | const QList< QKeySequence > & | shortcuts | ) |
Definition at line 345 of file qaction.cpp.
References d, QList< T >::isEmpty(), qApp, shortcuts(), and QList< T >::takeFirst().
Referenced by setShortcuts().
00346 { 00347 Q_D(QAction); 00348 00349 QList <QKeySequence> listCopy = shortcuts; 00350 00351 QKeySequence primary; 00352 if (!listCopy.isEmpty()) 00353 primary = listCopy.takeFirst(); 00354 00355 if (d->shortcut == primary && d->alternateShortcuts == listCopy) 00356 return; 00357 00358 d->shortcut = primary; 00359 d->alternateShortcuts = listCopy; 00360 d->redoGrab(qApp->d_func()->shortcutMap); 00361 d->redoGrabAlternate(qApp->d_func()->shortcutMap); 00362 d->sendDataChanged(); 00363 }
Here is the call graph for this function:

| void QAction::setShortcuts | ( | QKeySequence::StandardKey | key | ) |
Definition at line 375 of file qaction.cpp.
References QKeySequence::keyBindings(), and setShortcuts().
00376 { 00377 QList <QKeySequence> list = QKeySequence::keyBindings(key); 00378 setShortcuts(list); 00379 }
Here is the call graph for this function:

| QList< QKeySequence > QAction::shortcuts | ( | ) | const |
Definition at line 400 of file qaction.cpp.
References d.
Referenced by setShortcuts().
00401 { 00402 Q_D(const QAction); 00403 QList <QKeySequence> shortcuts; 00404 if (!d->shortcut.isEmpty()) 00405 shortcuts << d->shortcut; 00406 if (!d->alternateShortcuts.isEmpty()) 00407 shortcuts << d->alternateShortcuts; 00408 return shortcuts; 00409 }
| void QAction::setShortcutContext | ( | Qt::ShortcutContext | context | ) |
Definition at line 418 of file qaction.cpp.
Referenced by QDesignerToolWindow::QDesignerToolWindow().
00419 { 00420 Q_D(QAction); 00421 if (d->shortcutContext == context) 00422 return; 00423 d->shortcutContext = context; 00424 d->redoGrab(qApp->d_func()->shortcutMap); 00425 d->redoGrabAlternate(qApp->d_func()->shortcutMap); 00426 d->sendDataChanged(); 00427 }
| Qt::ShortcutContext QAction::shortcutContext | ( | ) | const |
| void QAction::setAutoRepeat | ( | bool | ) |
| bool QAction::autoRepeat | ( | ) | const |
| void QAction::setFont | ( | const QFont & | font | ) |
Definition at line 473 of file qaction.cpp.
Referenced by QDesignerMenuBar::QDesignerMenuBar(), and TextEdit::setupTextActions().
00474 { 00475 Q_D(QAction); 00476 if (d->font == font) 00477 return; 00478 00479 d->fontSet = true; 00480 d->font = font; 00481 d->sendDataChanged(); 00482 }
Here is the call graph for this function:

| QFont QAction::font | ( | ) | const |
Definition at line 484 of file qaction.cpp.
References d.
Referenced by QMenuPrivate::getStyleOption(), and setFont().
| void QAction::setCheckable | ( | bool | ) |
Definition at line 850 of file qaction.cpp.
References d.
Referenced by addAction(), MainWindow::addToMenu(), ColorSwatch::ColorSwatch(), QPixelTool::contextMenuEvent(), ImageViewer::createActions(), qdesigner_internal::createCheckableAction(), MainWindow::createMenu(), QVFb::createViewMenu(), QDockWidgetPrivate::init(), QToolBarPrivate::init(), Q3MainWindow::menuAboutToShow(), QDesignerActions::QDesignerActions(), QDesignerFormWindow::QDesignerFormWindow(), QDesignerToolWindow::QDesignerToolWindow(), QWhatsThisAction::QWhatsThisAction(), QToolBar::resizeEvent(), QFileDialogPrivate::setupActions(), MainWindow::setupDockWidgets(), TextEdit::setupTextActions(), ToolBar::ToolBar(), and MainWindow::updateWindowMenu().
00851 { 00852 Q_D(QAction); 00853 if (d->checkable == b) 00854 return; 00855 00856 d->checkable = b; 00857 d->checked = false; 00858 d->sendDataChanged(); 00859 }
| bool QAction::isCheckable | ( | ) | const |
Definition at line 861 of file qaction.cpp.
References d.
Referenced by QMenuPrivate::getStyleOption().
| QVariant QAction::data | ( | ) | const |
Returns the user data as set in QAction::setData.
Definition at line 1004 of file qaction.cpp.
References d.
Referenced by QCalendarWidgetPrivate::_q_monthChanged(), MainWindow::aboutToShowSaveAsMenu(), MainWindow::changeStyle(), MainWindow::checkCurrentStyle(), MainWindow::openRecentFile(), setData(), QDBusViewer::showContextMenu(), QDesignerToolBar::slotInsertSeparator(), QDesignerToolBar::slotRemoveSelectedAction(), QDesignerMenu::slotRemoveSelectedAction(), and QDesignerMenuBar::slotRemoveSelectedAction().
| void QAction::setData | ( | const QVariant & | userData | ) |
Sets the action's internal data to the given userData.
Definition at line 1018 of file qaction.cpp.
Referenced by QCalendarWidgetPrivate::createHeader(), QDesignerToolBar::handleContextMenuEvent(), QDesignerMenuBar::handleContextMenuEvent(), QDBusViewer::QDBusViewer(), qdesigner_internal::SetPropertyCommand::redo(), QDBusViewer::showContextMenu(), qdesigner_internal::SetPropertyCommand::undo(), and MainWindow::updateRecentFileActions().
Here is the call graph for this function:

| bool QAction::isChecked | ( | ) | const |
Definition at line 901 of file qaction.cpp.
References d.
Referenced by QActionGroupPrivate::_q_actionChanged(), QFileDialogPrivate::_q_showHidden(), QWhatsThisAction::actionTriggered(), MainWindow::addImage(), QPixelTool::contextMenuEvent(), ImageViewer::fitToWindow(), QMenuPrivate::getStyleOption(), ImageViewer::open(), MainWindow::setSettingsObject(), QAccessibleMenu::state(), TextEdit::textBold(), TextEdit::textItalic(), TextEdit::textUnderline(), QVFb::toggleCursor(), and ImageViewer::updateActions().
| bool QAction::isEnabled | ( | ) | const |
Definition at line 942 of file qaction.cpp.
References d.
Referenced by QMenuBarPrivate::activateAction(), QMenuPrivate::activateAction(), QAccessibleMenu::doAction(), QAccessibleMenuBar::doAction(), QMenuBarPrivate::getStyleOption(), QMenuPrivate::getStyleOption(), QMenuBarPrivate::popupAction(), QMenuPrivate::popupAction(), QAccessibleMenu::state(), and QAccessibleMenuBar::state().
| bool QAction::isVisible | ( | ) | const |
Definition at line 970 of file qaction.cpp.
References d.
Referenced by QToolBar::actionEvent(), and QMenuPrivate::filterActions().
| 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 1054 of file qaction.cpp.
References QMetaObject::addGuard(), d, emit, Hover, hovered(), QMetaObject::removeGuard(), setChecked(), and triggered().
Referenced by QMenuBarPrivate::activateAction(), QMenuPrivate::activateAction(), and event().
01055 { 01056 Q_D(QAction); 01057 if(event == Trigger) { 01058 QObject *guard = this; 01059 QMetaObject::addGuard(&guard); 01060 if(d->checkable) { 01061 // the checked action of an exclusive group cannot be unchecked 01062 if (d->checked && (d->group && d->group->isExclusive() 01063 && d->group->checkedAction() == this)) { 01064 QMetaObject::removeGuard(&guard); 01065 return; 01066 } 01067 setChecked(!d->checked); 01068 } 01069 if (guard) 01070 emit triggered(d->checked); 01071 #ifdef QT3_SUPPORT 01072 if (guard) 01073 emit activated(d->param); 01074 #endif 01075 QMetaObject::removeGuard(&guard); 01076 } else if(event == Hover) { 01077 emit hovered(); 01078 } 01079 }
Here is the call graph for this function:

| bool QAction::showStatusText | ( | QWidget * | widget = 0 |
) |
Updates the status bar for widget. If widget is an appropriate QStatusBar found for for this action based on the parent heirarchy will be used.
Definition at line 1034 of file qaction.cpp.
References object, QObject::parent(), QCoreApplication::sendEvent(), and statusTip().
Referenced by QMenuBarPrivate::activateAction(), and QMenuPrivate::activateAction().
01035 { 01036 #ifdef QT_NO_STATUSTIP 01037 Q_UNUSED(widget); 01038 #else 01039 if(QObject *object = widget ? widget : parent()) { 01040 QStatusTipEvent tip(statusTip()); 01041 QApplication::sendEvent(object, &tip); 01042 return true; 01043 } 01044 #endif 01045 return false; 01046 }
Here is the call graph for this function:

| void QAction::setMenuRole | ( | MenuRole | menuRole | ) |
Definition at line 1244 of file qaction.cpp.
References d.
Referenced by QDesignerActions::QDesignerActions().
01245 { 01246 Q_D(QAction); 01247 if (d->menuRole == menuRole) 01248 return; 01249 01250 d->menuRole = menuRole; 01251 d->sendDataChanged(); 01252 }
| QAction::MenuRole QAction::menuRole | ( | ) | const |
| QWidget * QAction::parentWidget | ( | ) | const |
Returns the parent widget.
Definition at line 298 of file qaction.cpp.
References QObject::isWidgetType(), and QObject::parent().
Referenced by QAbstractFormBuilder::createDom().
00299 { 00300 QObject *ret = parent(); 00301 while (ret && !ret->isWidgetType()) 00302 ret = ret->parent(); 00303 return (QWidget*)ret; 00304 }
Here is the call graph for this function:

Definition at line 312 of file qaction.cpp.
References d.
| bool QAction::event | ( | QEvent * | e | ) | [protected, virtual] |
Reimplemented from QObject.
Definition at line 980 of file qaction.cpp.
References activate(), QObject::event(), qWarning(), QEvent::Shortcut, and QEvent::type().
Referenced by QWidgetAction::event().
00981 { 00982 #ifndef QT_NO_SHORTCUT 00983 if (e->type() == QEvent::Shortcut) { 00984 QShortcutEvent *se = static_cast<QShortcutEvent *>(e); 00985 Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()), 00986 "QAction::event", 00987 "Received shortcut event from incorrect shortcut"); 00988 if (se->isAmbiguous()) 00989 qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", QString(se->key()).toLatin1().constData()); 00990 else 00991 activate(Trigger); 00992 return true; 00993 } 00994 #endif 00995 return QObject::event(e); 00996 }
Here is the call graph for this function:

| void QAction::trigger | ( | ) | [inline, slot] |
This is a convenience slot that calls activate(Trigger).
Definition at line 175 of file qaction.h.
Referenced by QDesignerWorkbench::addFormWindow(), MainWindow::checkCurrentStyle(), and qdesigner_internal::FormWindow::editWidgets().
| void QAction::hover | ( | ) | [inline, slot] |
| void QAction::setChecked | ( | bool | ) | [slot] |
Definition at line 888 of file qaction.cpp.
References d, emit, and toggled().
Referenced by QWorkspacePrivate::_q_updateActions(), activate(), addAction(), QDesignerWorkbench::addFormWindow(), TextEdit::alignmentChanged(), QDesignerFormWindow::changeEvent(), QPixelTool::contextMenuEvent(), qdesigner_internal::createCheckableAction(), QVFb::enableCursor(), TextEdit::fontChanged(), QDesignerToolWindow::hideEvent(), QWorkspacePrivate::init(), Q3MainWindow::menuAboutToShow(), QDesignerActions::QDesignerActions(), QFileDialogPrivate::setDirFilter(), QFileDialogPrivate::setDirSorting(), QFileDialogPrivate::setupActions(), MainWindow::setupDockWidgets(), QDesignerToolWindow::showEvent(), QDesignerWorkbench::switchToTopLevelMode(), toggle(), qdesigner_internal::RichTextEditorToolBar::updateActions(), ColorSwatch::updateContextMenu(), ToolBar::updateMenu(), and MainWindow::updateWindowMenu().
00889 { 00890 Q_D(QAction); 00891 if (!d->checkable || d->checked == b) 00892 return; 00893 00894 QPointer<QAction> guard(this); 00895 d->checked = b; 00896 d->sendDataChanged(); 00897 if (guard) 00898 emit toggled(b); 00899 }
| void QAction::toggle | ( | ) | [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 873 of file qaction.cpp.
References d, and setChecked().
00874 { 00875 Q_D(QAction); 00876 setChecked(!d->checked); 00877 }
| void QAction::setEnabled | ( | bool | ) | [slot] |
Definition at line 927 of file qaction.cpp.
Referenced by QFileDialogPrivate::_q_showContextMenu(), QWorkspacePrivate::_q_updateActions(), qdesigner_internal::ActionEditor::ActionEditor(), QView3DPlugin::activeFormWindowChanged(), qdesigner_internal::BuddyEditorPlugin::activeFormWindowChanged(), qdesigner_internal::SignalSlotEditorPlugin::activeFormWindowChanged(), QDesignerActions::activeFormWindowChanged(), qdesigner_internal::TabOrderEditorPlugin::activeFormWindowChanged(), QDesignerWorkbench::addFormWindow(), ToolBar::addSpinBox(), QtWindowListMenu::addWindow(), ColorSwatch::allow(), ToolBar::allow(), TextEdit::clipboardDataChanged(), SourceTextEdit::contextMenuEvent(), QAbstractSpinBox::contextMenuEvent(), QPixelTool::contextMenuEvent(), qdesigner_internal::QtGradientStopsWidget::contextMenuEvent(), ImageViewer::createActions(), MainWindow::createLetter(), QUndoStack::createRedoAction(), QUndoGroup::createRedoAction(), QUndoStack::createUndoAction(), QUndoGroup::createUndoAction(), qdesigner_internal::SignalSlotEditorPlugin::initialize(), qdesigner_internal::BuddyEditorPlugin::initialize(), qdesigner_internal::TabOrderEditorPlugin::initialize(), ConnectionWidget::on_tree_currentItemChanged(), ImageViewer::open(), MainWindow::openIniFile(), MainWindow::openPropertyList(), MainWindow::openRegistryPath(), MainWindow::openSettings(), ToolBar::order(), ToolBar::place(), ColorSwatch::place(), QDesignerActions::QDesignerActions(), QtWindowListMenu::QtWindowListMenu(), ToolBar::randomize(), QDesignerWorkbench::removeFormWindow(), ToolBar::removeSpinBox(), ImageViewer::scaleImage(), MainWindow::setActionsEnabled(), QtWindowListMenu::setEnabled(), qdesigner_internal::ActionEditor::setFormWindow(), MainWindow::setSettingsObject(), qdesigner_internal::FormWindowManager::setupActions(), TextEdit::setupEditActions(), Window::setVisible(), qdesigner_internal::ActionEditor::slotItemChanged(), qdesigner_internal::FormWindowManager::slotUpdateActions(), QDesignerTabWidget::tabInserted(), QDesignerTabWidget::tabRemoved(), qdesigner_internal::ContainerWidgetTaskMenu::taskActions(), TextEdit::TextEdit(), ToolBar::ToolBar(), ImageViewer::updateActions(), ColorSwatch::updateContextMenu(), ToolBar::updateMenu(), MainWindow::updateMenus(), and MainWindow::updateStyles().
00928 { 00929 Q_D(QAction); 00930 if (b == d->enabled && b != d->forceDisabled) 00931 return; 00932 d->forceDisabled = !b; 00933 if (b && d->group && !d->group->isEnabled()) 00934 return; 00935 d->enabled = b; 00936 #ifndef QT_NO_SHORTCUT 00937 d->setShortcutEnabled(b, qApp->d_func()->shortcutMap); 00938 #endif 00939 d->sendDataChanged(); 00940 }
| void QAction::setDisabled | ( | bool | b | ) | [inline, slot] |
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 180 of file qaction.h.
00180 { setEnabled(!b); }
| void QAction::setVisible | ( | bool | ) | [slot] |
Definition at line 959 of file qaction.cpp.
References d.
Referenced by MainWindow::aboutToShowSaveAsMenu(), QDesignerWorkbench::changeBringToFrontVisiblity(), QDesignerActions::QDesignerActions(), QWidgetAction::setDefaultWidget(), QDesignerWorkbench::switchToDockedMode(), QDesignerWorkbench::switchToTopLevelMode(), MainWindow::updateMenus(), MainWindow::updateRecentFileActions(), and MainWindow::updateWindowMenu().
00960 { 00961 Q_D(QAction); 00962 if (b == d->visible && b != d->forceInvisible) 00963 return; 00964 d->forceInvisible = !b; 00965 d->visible = b; 00966 d->sendDataChanged(); 00967 }
| void QAction::changed | ( | ) | [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.
| void QAction::triggered | ( | bool | checked = false |
) | [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().
| void QAction::hovered | ( | ) | [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().
| void QAction::toggled | ( | bool | checked | ) | [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 setChecked().
friend class QActionGroup [friend] |
friend class QShortcutMap [friend] |
friend class QToolButton [friend] |
1.5.1