<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QActionGroup Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QActionGroup Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QActionGroup class groups actions together. <a href="#details">More...</a></p> <p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qactiongroup.html#QActionGroup">__init__</a></b> (<i>self</i>, QObject <i>parent</i>)</li><li><div class="fn" />list-of-QAction <b><a href="qactiongroup.html#actions">actions</a></b> (<i>self</i>)</li><li><div class="fn" />QAction <b><a href="qactiongroup.html#addAction">addAction</a></b> (<i>self</i>, QAction <i>a</i>)</li><li><div class="fn" />QAction <b><a href="qactiongroup.html#addAction-2">addAction</a></b> (<i>self</i>, QString <i>text</i>)</li><li><div class="fn" />QAction <b><a href="qactiongroup.html#addAction-3">addAction</a></b> (<i>self</i>, QIcon <i>icon</i>, QString <i>text</i>)</li><li><div class="fn" />QAction <b><a href="qactiongroup.html#checkedAction">checkedAction</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qactiongroup.html#isEnabled">isEnabled</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qactiongroup.html#isExclusive">isExclusive</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qactiongroup.html#isVisible">isVisible</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qactiongroup.html#removeAction">removeAction</a></b> (<i>self</i>, QAction <i>a</i>)</li><li><div class="fn" /><b><a href="qactiongroup.html#setDisabled">setDisabled</a></b> (<i>self</i>, bool <i>b</i>)</li><li><div class="fn" /><b><a href="qactiongroup.html#setEnabled">setEnabled</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qactiongroup.html#setExclusive">setExclusive</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qactiongroup.html#setVisible">setVisible</a></b> (<i>self</i>, bool)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qactiongroup.html#hovered">hovered</a></b> (QAction *)</li><li><div class="fn" />void <b><a href="qactiongroup.html#selected">selected</a></b> (QAction *)</li><li><div class="fn" />void <b><a href="qactiongroup.html#triggered">triggered</a></b> (QAction *)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QActionGroup class groups actions together.</p> <p>In some situations it is useful to group <a href="qaction.html">QAction</a> objects together. For example, if you have a <b>Left Align</b> action, a <b>Right Align</b> action, a <b>Justify</b> action, and a <b>Center</b> action, only one of these actions should be active at any one time. One simple way of achieving this is to group the actions together in an action group.</p> <p>Here's a example (from the <a href="mainwindows-menus.html">Menus</a> example):</p> <pre class="cpp"> alignmentGroup <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QActionGroup</span>(<span class="keyword">this</span>); alignmentGroup<span class="operator">-</span><span class="operator">></span>addAction(leftAlignAct); alignmentGroup<span class="operator">-</span><span class="operator">></span>addAction(rightAlignAct); alignmentGroup<span class="operator">-</span><span class="operator">></span>addAction(justifyAct); alignmentGroup<span class="operator">-</span><span class="operator">></span>addAction(centerAct); leftAlignAct<span class="operator">-</span><span class="operator">></span>setChecked(<span class="keyword">true</span>); </pre> <p>Here we create a new action group. Since the action group is exclusive by default, only one of the actions in the group is checked at any one time.</p> <p class="centerAlign"><img alt="Alignment options in a QMenu" src="images/qactiongroup-align.png" /></p> <p>A QActionGroup emits an <a href="qactiongroup.html#triggered">triggered</a>() signal when one of its actions is chosen. Each action in an action group emits its <a href="qactiongroup.html#triggered">triggered</a>() signal as usual.</p> <p>As stated above, an action group is <a href="qactiongroup.html#exclusive-prop">exclusive</a> by default; it ensures that only one checkable action is active at any one time. If you want to group checkable actions without making them exclusive, you can turn of exclusiveness by calling setExclusive(false).</p> <p>Actions can be added to an action group using <a href="qactiongroup.html#addAction">addAction</a>(), but it is usually more convenient to specify a group when creating actions; this ensures that actions are automatically created with a parent. Actions can be visually separated from each other by adding a separator action to the group; create an action and use <a href="qaction.html">QAction</a>'s <a href="qaction.html#setSeparator">setSeparator()</a> function to make it considered a separator. Action groups are added to widgets with the <a href="qwidget.html#addActions">QWidget.addActions</a>() function.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QActionGroup" />QActionGroup.__init__ (<i>self</i>, <a href="qobject.html">QObject</a> <i>parent</i>)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs an action group for the <i>parent</i> object.</p> <p>The action group is exclusive by default. Call setExclusive(false) to make the action group non-exclusive.</p> <h3 class="fn"><a name="actions" />list-of-QAction QActionGroup.actions (<i>self</i>)</h3><p>Returns the list of this groups's actions. This may be empty.</p> <h3 class="fn"><a name="addAction" /><a href="qaction.html">QAction</a> QActionGroup.addAction (<i>self</i>, <a href="qaction.html">QAction</a> <i>a</i>)</h3><p>The <i>a</i> argument has it's ownership transferred to Qt.</p><p>Adds the <i>action</i> to this group, and returns it.</p> <p>Normally an action is added to a group by creating it with the group as its parent, so this function is not usually used.</p> <p><b>See also</b> <a href="qaction.html#setActionGroup">QAction.setActionGroup</a>().</p> <h3 class="fn"><a name="addAction-2" /><a href="qaction.html">QAction</a> QActionGroup.addAction (<i>self</i>, QString <i>text</i>)</h3><p>Creates and returns an action with <i>text</i>. The newly created action is a child of this action group.</p> <p>Normally an action is added to a group by creating it with the group as parent, so this function is not usually used.</p> <p><b>See also</b> <a href="qaction.html#setActionGroup">QAction.setActionGroup</a>().</p> <h3 class="fn"><a name="addAction-3" /><a href="qaction.html">QAction</a> QActionGroup.addAction (<i>self</i>, <a href="qicon.html">QIcon</a> <i>icon</i>, QString <i>text</i>)</h3><p>Creates and returns an action with <i>text</i> and an <i>icon</i>. The newly created action is a child of this action group.</p> <p>Normally an action is added to a group by creating it with the group as its parent, so this function is not usually used.</p> <p><b>See also</b> <a href="qaction.html#setActionGroup">QAction.setActionGroup</a>().</p> <h3 class="fn"><a name="checkedAction" /><a href="qaction.html">QAction</a> QActionGroup.checkedAction (<i>self</i>)</h3><p>Returns the currently checked action in the group, or 0 if none are checked.</p> <h3 class="fn"><a name="isEnabled" />bool QActionGroup.isEnabled (<i>self</i>)</h3><h3 class="fn"><a name="isExclusive" />bool QActionGroup.isExclusive (<i>self</i>)</h3><h3 class="fn"><a name="isVisible" />bool QActionGroup.isVisible (<i>self</i>)</h3><h3 class="fn"><a name="removeAction" />QActionGroup.removeAction (<i>self</i>, <a href="qaction.html">QAction</a> <i>a</i>)</h3><p>The <i>a</i> argument</p><p>Removes the <i>action</i> from this group. The action will have no parent as a result.</p> <p><b>See also</b> <a href="qaction.html#setActionGroup">QAction.setActionGroup</a>().</p> <h3 class="fn"><a name="setDisabled" />QActionGroup.setDisabled (<i>self</i>, bool <i>b</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setDisabled(bool)</tt>.</p><p>This is a convenience function for the <a href="qactiongroup.html#enabled-prop">enabled</a> property, that is useful for signals--slots connections. If <i>b</i> is true the action group is disabled; otherwise it is enabled.</p> <h3 class="fn"><a name="setEnabled" />QActionGroup.setEnabled (<i>self</i>, bool)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setEnabled(bool)</tt>.</p><h3 class="fn"><a name="setExclusive" />QActionGroup.setExclusive (<i>self</i>, bool)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setExclusive(bool)</tt>.</p><h3 class="fn"><a name="setVisible" />QActionGroup.setVisible (<i>self</i>, bool)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setVisible(bool)</tt>.</p><hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="hovered" />void hovered (QAction *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the given <i>action</i> in the action group 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.</p> <p><b>See also</b> <a href="qaction.html#activate">QAction.activate</a>().</p> <h3 class="fn"><a name="selected" />void selected (QAction *)</h3><p>This is the default overload of this signal.</p><h3 class="fn"><a name="triggered" />void triggered (QAction *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the given <i>action</i> in the action group is activated by the user; for example, when the user clicks a menu option, toolbar button, or presses an action's shortcut key combination.</p> <p>Connect to this signal for command actions.</p> <p><b>See also</b> <a href="qaction.html#activate">QAction.activate</a>().</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>