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 32
|
<?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>QKeyEvent 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">QKeyEvent Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QKeyEvent class contains describes a key event. <a href="#details">More...</a></p>
<p>Inherits <a href="qinputevent.html">QInputEvent</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qkeyevent.html#QKeyEvent">__init__</a></b> (<i>self</i>, QEvent.Type <i>type</i>, int <i>key</i>, Qt.KeyboardModifiers <i>modifiers</i>, QString <i>text</i> = QString(), bool <i>autorep</i> = False, unsigned long <i>count</i> = 1)</li><li><div class="fn" /><b><a href="qkeyevent.html#QKeyEvent-2">__init__</a></b> (<i>self</i>, QKeyEvent)</li><li><div class="fn" />int <b><a href="qkeyevent.html#count">count</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qkeyevent.html#isAutoRepeat">isAutoRepeat</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qkeyevent.html#key">key</a></b> (<i>self</i>)</li><li><div class="fn" />Qt.KeyboardModifiers <b><a href="qkeyevent.html#modifiers">modifiers</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qkeyevent.html#text">text</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QKeyEvent class contains describes a key event.</p>
<p>Key events are sent to the widget with keyboard input focus when keys are pressed or released.</p>
<p>A key event contains a special accept flag that indicates whether the receiver will handle the key event. You should call <a href="qevent.html#ignore">ignore</a>() if the key press or release event is not handled by your widget. A key event is propagated up the parent widget chain until a widget accepts it with <a href="qevent.html#accept">accept</a>() or an event filter consumes it. Key events for multimedia keys are ignored by default. You should call <a href="qevent.html#accept">accept</a>() if your widget handles those events.</p>
<p>The QWidget.setEnable() function can be used to enable or disable mouse and keyboard events for a widget.</p>
<p>The event handlers <a href="qwidget.html#keyPressEvent">QWidget.keyPressEvent</a>() and <a href="qwidget.html#keyReleaseEvent">QWidget.keyReleaseEvent</a>() receive key events.</p>
<p>See also <a href="qfocusevent.html">QFocusEvent</a> and <a href="qwidget.html#grabKeyboard">QWidget.grabKeyboard</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QKeyEvent" />QKeyEvent.__init__ (<i>self</i>, <a href="qevent.html#Type-enum">QEvent.Type</a> <i>type</i>, int <i>key</i>, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifiers</i>, <a href="qstring.html">QString</a> <i>text</i> = QString(), bool <i>autorep</i> = False, unsigned long <i>count</i> = 1)</h3><p>Constructs a key event object.</p>
<p>The <i>type</i> parameter must be <a href="qevent.html#Type-enum">QEvent.KeyPress</a>, <a href="qevent.html#Type-enum">QEvent.KeyRelease</a>, or <a href="qevent.html#Type-enum">QEvent.ShortcutOverride</a>.</p>
<p>If <i>key</i> is 0, the event is not a result of a known key; for example, it may be the result of a compose sequence or keyboard macro. The <i>modifiers</i> holds the keyboard modifiers, and the given <i>text</i> is the Unicode text that the key generated. If <i>autorep</i> is true, <a href="qkeyevent.html#isAutoRepeat">isAutoRepeat</a>() will be true. <i>count</i> is the number of keys involved in the event.</p>
<h3 class="fn"><a name="QKeyEvent-2" />QKeyEvent.__init__ (<i>self</i>, <a href="qkeyevent.html">QKeyEvent</a>)</h3><h3 class="fn"><a name="count" />int QKeyEvent.count (<i>self</i>)</h3><p>Returns the number of keys involved in this event. If <a href="qkeyevent.html#text">text</a>() is not empty, this is simply the length of the string.</p>
<p>See also <a href="qt.html#WidgetAttribute-enum">Qt.WA_KeyCompression</a>.</p>
<h3 class="fn"><a name="isAutoRepeat" />bool QKeyEvent.isAutoRepeat (<i>self</i>)</h3><p>Returns true if this event comes from an auto-repeating key; returns false if it comes from an initial key press.</p>
<p>Note that if the event is a multiple-key compressed event that is partly due to auto-repeat, this function could return either true or false indeterminately.</p>
<h3 class="fn"><a name="key" />int QKeyEvent.key (<i>self</i>)</h3><p>Returns the code of the key that was pressed or released.</p>
<p>See <a href="qt.html#Key-enum">Qt.Key</a> for the list of keyboard codes. These codes are independent of the underlying window system. Note that this function does not distinguish between capital and non-capital letters, use the <a href="qkeyevent.html#text">text</a>() function (returning the Unicode text the key generated) for this purpose.</p>
<p>A value of either 0 or <a href="qt.html#Key-enum">Qt.Key_unknown</a> means that the event is not the result of a known key; for example, it may be the result of a compose sequence, a keyboard macro, or due to key event compression.</p>
<p>See also <a href="qt.html#WidgetAttribute-enum">Qt.WA_KeyCompression</a>.</p>
<h3 class="fn"><a name="modifiers" /><a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> QKeyEvent.modifiers (<i>self</i>)</h3><p>Returns the keyboard modifier flags that existed immediately after the event occurred.</p>
<p><b>Warning:</b> This function cannot always be trusted. The user can confuse it by pressing both <b>Shift</b> keys simulatenously and releasing one of them, for example.</p>
<p>See also <a href="qapplication.html#keyboardModifiers">QApplication.keyboardModifiers</a>().</p>
<h3 class="fn"><a name="text" /><a href="qstring.html">QString</a> QKeyEvent.text (<i>self</i>)</h3><p>Returns the Unicode text that this key generated. The text returned can be an empty string in cases where modifier keys, such as Shift, Control, Alt, and Meta, are being pressed or released. In such cases <a href="qkeyevent.html#key">key</a>() will contain a valid value.</p>
<p>See also <a href="qt.html#WidgetAttribute-enum">Qt.WA_KeyCompression</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>
|