1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
<?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>QShortcut 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="../pyqt4ref.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">QShortcut Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QShortcut class is used to create keyboard shortcuts. <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="qshortcut.html#QShortcut">__init__</a></b> (<i>self</i>, QWidget <i>parent</i>)</li><li><div class="fn" /><b><a href="qshortcut.html#QShortcut-2">__init__</a></b> (<i>self</i>, QKeySequence <i>key</i>, QWidget <i>parent</i>, SLOT() <i>member</i> = 0, SLOT() <i>ambiguousMember</i> = 0, Qt.ShortcutContext <i>context</i> = Qt.WindowShortcut)</li><li><div class="fn" />Qt.ShortcutContext <b><a href="qshortcut.html#context">context</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qshortcut.html#event">event</a></b> (<i>self</i>, QEvent <i>e</i>)</li><li><div class="fn" />int <b><a href="qshortcut.html#id">id</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qshortcut.html#isEnabled">isEnabled</a></b> (<i>self</i>)</li><li><div class="fn" />QKeySequence <b><a href="qshortcut.html#key">key</a></b> (<i>self</i>)</li><li><div class="fn" />QWidget <b><a href="qshortcut.html#parentWidget">parentWidget</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qshortcut.html#setContext">setContext</a></b> (<i>self</i>, Qt.ShortcutContext <i>context</i>)</li><li><div class="fn" /><b><a href="qshortcut.html#setEnabled">setEnabled</a></b> (<i>self</i>, bool <i>enable</i>)</li><li><div class="fn" /><b><a href="qshortcut.html#setKey">setKey</a></b> (<i>self</i>, QKeySequence <i>key</i>)</li><li><div class="fn" /><b><a href="qshortcut.html#setWhatsThis">setWhatsThis</a></b> (<i>self</i>, QString <i>text</i>)</li><li><div class="fn" />QString <b><a href="qshortcut.html#whatsThis">whatsThis</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qshortcut.html#activated">activated</a></b> ()</li><li><div class="fn" />void <b><a href="qshortcut.html#activatedAmbiguously">activatedAmbiguously</a></b> ()</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QShortcut class is used to create keyboard shortcuts.</p>
<p>The QShortcut class provides a way of connecting keyboard shortcuts to Qt's <a href="signalsandslots.html">signals and slots</a> mechanism, so that objects can be informed when a shortcut is executed. The shortcut can be set up to contain all the key presses necessary to describe a keyboard shortcut, including the states of modifier keys such as <b>Shift</b>, <b>Ctrl</b>, and <b>Alt</b>.</p>
<p>For applications that use menus, it may be more convenient to use the convenience functions provided in the <a href="qmenu.html">QMenu</a> class to assign keyboard shortcuts to menu items as they are created. Alternatively, shortcuts may be associated with other types of actions in the <a href="qaction.html">QAction</a> class.</p>
<p>The simplest way to create a shortcut for a particular widget is to construct the shortcut with a key sequence. For example:</p>
<pre>
shortcut = QShortcut(QKeySequence(tr("Ctrl+O", "File|Open")),
parent);
</pre>
<p>When the user types the <a href="qkeysequence.html">key sequence</a> for a given shortcut, the shortcut's <a href="qshortcut.html#activated">activated</a>() signal is emitted. (In the case of ambiguity, the <a href="qshortcut.html#activatedAmbiguously">activatedAmbiguously</a>() signal is emitted.) A shortcut is "listened for" by Qt's event loop when the shortcut's parent widget is receiving events.</p>
<p>A shortcut's key sequence can be set with <a href="qshortcut.html#key-prop">setKey</a>() and retrieved with <a href="qshortcut.html#key-prop">key</a>(). A shortcut can be enabled or disabled with <a href="qshortcut.html#enabled-prop">setEnabled</a>(), and can have "What's This?" help text set with <a href="qshortcut.html#whatsThis-prop">setWhatsThis</a>().</p>
<p>See also <a href="qshortcutevent.html">QShortcutEvent</a>, <a href="qkeysequence.html">QKeySequence</a>, and <a href="qaction.html">QAction</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QShortcut" />QShortcut.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</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 a <a href="qshortcut.html">QShortcut</a> object for the <i>parent</i> widget. Since no shortcut key sequence is specified, the shortcut will not emit any signals.</p>
<p>See also <a href="qshortcut.html#key-prop">setKey</a>().</p>
<h3 class="fn"><a name="QShortcut-2" />QShortcut.__init__ (<i>self</i>, <a href="qkeysequence.html">QKeySequence</a> <i>key</i>, <a href="qwidget.html">QWidget</a> <i>parent</i>, SLOT() <i>member</i> = 0, SLOT() <i>ambiguousMember</i> = 0, <a href="qt.html#ShortcutContext-enum">Qt.ShortcutContext</a> <i>context</i> = Qt.WindowShortcut)</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 a <a href="qshortcut.html">QShortcut</a> object for the <i>parent</i> widget. The shortcut operates on its parent, listening for <a href="qshortcutevent.html">QShortcutEvent</a>s that match the <i>key</i> sequence. Depending on the ambiguity of the event, the shortcut will call the <i>member</i> function, or the <i>ambiguousMember</i> function, if the key press was in the shortcut's <i>context</i>.</p>
<h3 class="fn"><a name="context" /><a href="qt.html#ShortcutContext-enum">Qt.ShortcutContext</a> QShortcut.context (<i>self</i>)</h3><h3 class="fn"><a name="event" />bool QShortcut.event (<i>self</i>, <a href="qevent.html">QEvent</a> <i>e</i>)</h3><h3 class="fn"><a name="id" />int QShortcut.id (<i>self</i>)</h3><p>Returns the shortcut's ID.</p>
<p>See also <a href="qshortcutevent.html#shortcutId">QShortcutEvent.shortcutId</a>().</p>
<h3 class="fn"><a name="isEnabled" />bool QShortcut.isEnabled (<i>self</i>)</h3><h3 class="fn"><a name="key" /><a href="qkeysequence.html">QKeySequence</a> QShortcut.key (<i>self</i>)</h3><h3 class="fn"><a name="parentWidget" /><a href="qwidget.html">QWidget</a> QShortcut.parentWidget (<i>self</i>)</h3><p>Returns the shortcut's parent widget.</p>
<h3 class="fn"><a name="setContext" />QShortcut.setContext (<i>self</i>, <a href="qt.html#ShortcutContext-enum">Qt.ShortcutContext</a> <i>context</i>)</h3><h3 class="fn"><a name="setEnabled" />QShortcut.setEnabled (<i>self</i>, bool <i>enable</i>)</h3><h3 class="fn"><a name="setKey" />QShortcut.setKey (<i>self</i>, <a href="qkeysequence.html">QKeySequence</a> <i>key</i>)</h3><h3 class="fn"><a name="setWhatsThis" />QShortcut.setWhatsThis (<i>self</i>, <a href="qstring.html">QString</a> <i>text</i>)</h3><h3 class="fn"><a name="whatsThis" /><a href="qstring.html">QString</a> QShortcut.whatsThis (<i>self</i>)</h3><hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="activated" />void activated ()</h3><p>This signal is emitted when the user types the shortcut's key sequence.</p>
<p>See also <a href="qshortcut.html#activatedAmbiguously">activatedAmbiguously</a>().</p>
<h3 class="fn"><a name="activatedAmbiguously" />void activatedAmbiguously ()</h3><p>This signal is emitted when the user types a shortcut key sequence that is ambiguous. For example, if one key sequence is a "prefix" for another and the user types these keys it isn't clear if they want the shorter key sequence, or if they're about to type more to complete the longer key sequence.</p>
<p>See also <a href="qshortcut.html#activated">activated</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|