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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QKeyEvent Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QKeyEvent Class Reference</h1><br clear="all">
<p>
The QKeyEvent class contains parameters that describe a key event.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qevent-h.html">qevent.h</a>></code>
<p>
Inherits <a href="qevent.html">QEvent</a>.
<p><a href="qkeyevent-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#66d690"><b>QKeyEvent</b></a>(Typetype, intkey, intascii, intstate, constQString&text=QString::null, boolautorep=FALSE, ushortcount=1)</div>
<li><div class="fn">int<a href="#b1e63d"><b>key</b></a>()const</div>
<li><div class="fn">int<a href="#f0af69"><b>ascii</b></a>()const</div>
<li><div class="fn">ButtonState<a href="#c65df4"><b>state</b></a>()const</div>
<li><div class="fn">ButtonState<a href="#c980e8"><b>stateAfter</b></a>()const</div>
<li><div class="fn">bool<a href="#006d82"><b>isAccepted</b></a>()const</div>
<li><div class="fn">QString<a href="#882dd8"><b>text</b></a>()const</div>
<li><div class="fn">bool<a href="#7c7e1e"><b>isAutoRepeat</b></a>()const</div>
<li><div class="fn">int<a href="#ddfc7a"><b>count</b></a>()const</div>
<li><div class="fn">void<a href="#ae446e"><b>accept</b></a>()</div>
<li><div class="fn">void<a href="#d9375a"><b>ignore</b></a>()</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QKeyEvent class contains parameters that describe a key event.
<p>
Key events occur when a key is pressed or released when a widget has
keyboard input focus.
<p>A key event contains a special accept flag which tells whether the
receiver wants the key. You should call <a href="#d9375a">QKeyEvent::ignore</a>() if the
key press or release event is not handled by your widget.
<p>The QWidget::setEnable() function can be used to enable or disable mouse
and keyboard events for a widget.
<p>The event handlers <a href="qwidget.html#0a4482">QWidget::keyPressEvent</a>() and <a href="qwidget.html#4b620f">QWidget::keyReleaseEvent</a>()
receive key events.
<p>See also <a href="qfocusevent.html">QFocusEvent</a> and <a href="qwidget.html#6830ee">QWidget::grabKeyboard</a>().
<p>Examples:
<a href="picture-picture-cpp.html#QKeyEvent">picture/picture.cpp</a>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="66d690"></a>QKeyEvent::QKeyEvent(<a href="qevent.html#Type">Type</a>type, intkey, intascii, intstate, const<a href="qstring.html">QString</a>&text=QString::null, boolautorep=FALSE, ushortcount=1)</h3>
<p>Constructs a key event object.
<p>The <em>type</em> parameter must be <code>QEvent::KeyPress</code> or <code>QEvent::KeyRelease.</code>
<p>If <em>key</em> is 0, the event is not a result of a known key (e.g. it
may be the result of a compose sequence or keyboard macro).
<p><em>text</em> will be returned by <a href="#882dd8">text</a>().
<p>If <em>autorep</em> is TRUE then <a href="#7c7e1e">isAutoRepeat</a>() will be TRUE.
<p><em>count</em> is the number of single keys.
<p>The accept flag is set to TRUE.
<h3 class="fn">void<a name="ae446e"></a>QKeyEvent::accept()</h3>
<p>Sets the accept flag of the key event object.
<p>Setting the accept parameter indicates that the receiver of the event wants
the key event. Unwanted key events are sent to the parent widget.
<p>The accept flag is set by default.
<p>See also <a href="#d9375a">ignore</a>().
<h3 class="fn">int<a name="f0af69"></a>QKeyEvent::ascii()const</h3>
<p>Returns the ASCII code of the key that was pressed or released.
We recommend using <a href="#882dd8">text</a>() instead.
<p>See also <a href="#882dd8">text</a>().
<p>Examples:
<a href="picture-picture-cpp.html#ascii">picture/picture.cpp</a>
<h3 class="fn">int<a name="ddfc7a"></a>QKeyEvent::count()const</h3>
<p>Returns the number of single keys for this event. If <a href="#882dd8">text</a>() is not
empty, this is simply the length of the string.
<p>However, Qt also compresses invisible keycodes, such as BackSpace.
For those, count() returns the number of key presses/repeats this
event represents.
<p>See also <a href="qwidget.html#55438e">QWidget::setKeyCompression</a>().
<h3 class="fn">void<a name="d9375a"></a>QKeyEvent::ignore()</h3>
<p>Clears the accept flag parameter of the key event object.
<p>Clearing the accept parameter indicates that the event receiver does
not want the key event. Unwanted key events are sent to the parent
widget.
<p>The accept flag is set by default.
<p>See also <a href="#ae446e">accept</a>().
<h3 class="fn">bool<a name="006d82"></a>QKeyEvent::isAccepted()const</h3>
<p>Returns TRUE if the receiver of the event wants to keep the key.
<h3 class="fn">bool<a name="7c7e1e"></a>QKeyEvent::isAutoRepeat()const</h3>
<p>Returns TRUE if this event comes from an auto-repeating key and
FALSE if it comes from an initial press.
<p>Note that if the event is a multiple-key compressed event which
partly is due to autorepeat, this function returns an indeterminate
value.
<h3 class="fn">int<a name="b1e63d"></a>QKeyEvent::key()const</h3>
<p>Returns the code of the key that was pressed or released.
<p>The header file <a href="qnamespace-h.html">qnamespace.h</a> lists the possible keyboard codes. These codes
are independent of the underlying window system.
<p>Key code 0 means that the event is not a result of a known key (e.g. it
may be the result of a compose sequence or keyboard macro).
<h3 class="fn"><a href="qt.html#ButtonState">ButtonState</a><a name="c65df4"></a>QKeyEvent::state()const</h3>
<p>Returns the keyboard modifier flags that existed immediately before
the event occurred.
<p>The returned value is <code>ShiftButton, ControlButton</code> and <code>AltButton</code>
OR'ed together.
<p>See also <a href="#c980e8">stateAfter</a>().
<h3 class="fn"><a href="qt.html#ButtonState">ButtonState</a><a name="c980e8"></a>QKeyEvent::stateAfter()const</h3>
<p>Returns the keyboard modifier flags that existed immediately after
the event occurred.<p><b>Warning:</b> This function cannot be trusted.
<p>See also <a href="#c65df4">state</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="882dd8"></a>QKeyEvent::text()const</h3>
<p>Returns the Unicode text which this key generated.
<p>See also <a href="qwidget.html#55438e">QWidget::setKeyCompression</a>().
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|