Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Properties | Friends | Related Functions

QAction Class Reference

The QAction class provides an abstract user interface action that can be inserted into widgets. More...

Inheritance diagram for QAction:
Inheritance graph
[legend]
Collaboration diagram for QAction:
Collaboration graph
[legend]

List of all members.

Public Types

enum  ActionEvent { Trigger, Hover }
enum  MenuRole {
  NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole,
  AboutRole, PreferencesRole, QuitRole
}

Public Slots

void deleteLater ()
void hover ()
void setChecked (bool)
void setDisabled (bool b)
void setEnabled (bool)
void setVisible (bool)
void toggle ()
void trigger ()

Signals

void changed ()
void destroyed (QObject *=0)
void hovered ()
void toggled (bool)
void triggered (bool checked=false)

Public Member Functions

QActionGroupactionGroup () const
void activate (ActionEvent event)
QList< QGraphicsWidget * > associatedGraphicsWidgets () const
QList< QWidget * > associatedWidgets () const
bool autoRepeat () const
bool blockSignals (bool b)
const QObjectListchildren () const
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
QVariant data () 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 ()
void dumpObjectTree ()
QList< QByteArraydynamicPropertyNames () const
virtual bool eventFilter (QObject *, QEvent *)
template<typename T >
findChild (const QString &aName=QString()) const
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
template<typename T >
QList< T > findChildren (const QRegExp &re) const
QFont font () const
QIcon icon () const
QString iconText () const
bool inherits (const char *classname) const
void installEventFilter (QObject *)
bool isCheckable () const
bool isChecked () const
bool isEnabled () const
bool isIconVisibleInMenu () const
bool isSeparator () const
bool isVisible () const
bool isWidgetType () const
void killTimer (int id)
QMenumenu () const
MenuRole menuRole () const
void moveToThread (QThread *thread)
QString objectName () const
QObjectparent () const
QWidgetparentWidget () const
QVariant property (const char *name) const
 QAction (const QString &text, QObject *parent)
 QAction (QObject *parent)
 QAction (const QIcon &icon, const QString &text, QObject *parent)
void removeEventFilter (QObject *)
void setActionGroup (QActionGroup *group)
void setAutoRepeat (bool)
void setCheckable (bool)
void setData (const QVariant &var)
void setFont (const QFont &font)
void setIcon (const QIcon &icon)
void setIconText (const QString &text)
void setIconVisibleInMenu (bool visible)
void setMenu (QMenu *menu)
void setMenuRole (MenuRole menuRole)
void setObjectName (const QString &name)
void setParent (QObject *)
bool setProperty (const char *name, const QVariant &value)
void setSeparator (bool b)
void setShortcut (const QKeySequence &shortcut)
void setShortcutContext (Qt::ShortcutContext context)
void setShortcuts (QKeySequence::StandardKey)
void setShortcuts (const QList< QKeySequence > &shortcuts)
void setStatusTip (const QString &statusTip)
void setText (const QString &text)
void setToolTip (const QString &tip)
void setUserData (uint id, QObjectUserData *data)
void setWhatsThis (const QString &what)
QKeySequence shortcut () const
Qt::ShortcutContext shortcutContext () const
QList< QKeySequenceshortcuts () const
bool showStatusText (QWidget *widget=0)
bool signalsBlocked () const
int startTimer (int interval)
QString statusTip () const
QString text () const
QThreadthread () const
QString toolTip () const
QObjectUserDatauserData (uint id) const
QString whatsThis () const
 ~QAction ()

Static Public Member Functions

static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static uint registerUserData ()

Protected Member Functions

virtual void childEvent (QChildEvent *)
virtual void connectNotify (const char *signal)
virtual void customEvent (QEvent *)
virtual void disconnectNotify (const char *signal)
bool event (QEvent *)
 QAction (QActionPrivate &dd, QObject *parent)
int receivers (const char *signal) const
QObjectsender () const
virtual void timerEvent (QTimerEvent *)

Protected Attributes

QObjectDatad_ptr

Static Protected Attributes

static const QMetaObject staticQtMetaObject

Properties

bool autoRepeat
 whether the action can auto repeat
bool checkable
 whether the action is a checkable action
bool checked
 whether the action is checked.
bool enabled
 whether the action is enabled
QFont font
 the action's font
QIcon icon
 the action's icon
QString iconText
 the action's descriptive icon text
bool iconVisibleInMenu
 Whether or not an action should show an icon in a menu.
MenuRole menuRole
 the action's menu role
QString objectName
 the name of this object
QKeySequence shortcut
 the action's primary shortcut key
Qt::ShortcutContext shortcutContext
 the context for the action's shortcut
QString statusTip
 the action's status tip
QString text
 the action's descriptive text
QString toolTip
 the action's tooltip
bool visible
 whether the action can be seen (e.g. in menus and toolbars)
QString whatsThis
 the action's "What's This?" help text

Friends

class QActionGroup
class QApplication
class QApplicationPrivate
class QCoreApplication
class QCoreApplicationPrivate
class QGraphicsWidget
class QMenu
class QMenuBar
class QMenuPrivate
struct QMetaObject
class QShortcutMap
class QThreadData
class QToolButton
class QWidget

Related Functions

(Note that these are not member functions.)


qFindChild (const QObject *obj, const QString &name)
qFindChildqFindChildren (const QObject *obj, const QString &name=QString(), T dummy=0)()
QList< T > qFindChildren (const QObject *obj, const QString &name)
QList< T > qFindChildrenqFindChildren (const QObject *obj, const QRegExp &regExp)()
QList< T > qFindChildrenqFindChildren (const QObject *obj, const QString &name=QString(), T dummy=0)()
T * qobject_cast (QObject *object)
 QObjectList
void * qt_find_obj_child (QObject *parent, const char *type, const QString &name)

Detailed Description

The QAction class provides an abstract user interface action that can be inserted into widgets.

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() 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:

examples/mainwindows/application/mainwindow.cpp 19 examples/mainwindows/application/mainwindow.cpp 28 examples/mainwindows/application/mainwindow.cpp 31

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.

See also:
QMenu, QToolBar, {Application Example}

Definition at line 64 of file qaction.h.


The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index