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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta name="robots" content="noindex,noarchive">
<title>Qt Toolkit - QAccel Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 15%; text-indent: -15%; }
a:link { text-decoration: none; }
--></style>
</head><body bgcolor="#ffffff">
<a href=index.html><img width=122 height=65 src=qtlogo.jpg alt="Qt logo" align=left border=0></a>
<center><img src=dochead.gif width=472 height=27></center>
<br clear=all>
<h1 align=center>QAccel Class Reference</h1><br clear="all">
<p>
The QAccel class handles keyboard accelerator keys.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qaccel-h.html">qaccel.h</a>></code>
<p>
Inherits <a href="qobject.html">QObject</a>.
<p><a href="qaccel-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><span class="fn"><a href="qaccel.html#a0"><strong>QAccel</strong></a>(QWidget*parent, constchar*name=0)</span>
<li><span class="fn"><a href="qaccel.html#a1"><strong>~QAccel</strong></a>()</span>
<li><span class="fn">bool<a href="qaccel.html#a2"><strong>isEnabled</strong></a>()const</span>
<li><span class="fn">void<a href="qaccel.html#a3"><strong>setEnabled</strong></a>(bool)</span>
<li><span class="fn">uint<a href="qaccel.html#a4"><strong>count</strong></a>()const</span>
<li><span class="fn">int<a href="qaccel.html#a5"><strong>insertItem</strong></a>(intkey, intid=-1)</span>
<li><span class="fn">void<a href="qaccel.html#a6"><strong>removeItem</strong></a>(intid)</span>
<li><span class="fn">void<a href="qaccel.html#a7"><strong>clear</strong></a>()</span>
<li><span class="fn">int<a href="qaccel.html#a8"><strong>key</strong></a>(intid)</span>
<li><span class="fn">int<a href="qaccel.html#a9"><strong>findKey</strong></a>(intkey)const</span>
<li><span class="fn">bool<a href="qaccel.html#b0"><strong>isItemEnabled</strong></a>(intid)const</span>
<li><span class="fn">void<a href="qaccel.html#b1"><strong>setItemEnabled</strong></a>(intid, boolenable)</span>
<li><span class="fn">bool<a href="qaccel.html#b2"><strong>connectItem</strong></a>(intid, constQObject*receiver, constchar*member)</span>
<li><span class="fn">bool<a href="qaccel.html#b3"><strong>disconnectItem</strong></a>(intid, constQObject*receiver, constchar*member)</span>
<li><span class="fn">void<a href="qaccel.html#b4"><strong>repairEventFilter</strong></a>()</span>
</ul>
<h2>Signals</h2>
<ul>
<li><span class="fn">void<a href="qaccel.html#b5"><strong>activated</strong></a>(intid)</span>
</ul>
<h2>Protected Members</h2>
<ul>
<li><span class="fn">virtualbool<a href="qaccel.html#b6"><strong>eventFilter</strong></a>(QObject*, QEvent*)</span>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QAccel class handles keyboard accelerator keys.
<p>
A QAccel contains a list of accelerator items. Each accelerator item
consists of an identifier and a keyboard code combined with modifiers
(<code>SHIFT, CTRL, ALT</code> or <code>ASCII_ACCEL).</code>
<p>For example, <code>CTRL + Key_P</code> could be a shortcut for printing
a document. The key codes are listed in <a href="qkeycode-h.html">qkeycode.h</a>.
<p>When pressed, an accelerator key sends out the signal <a href="qaccel.html#b5">activated</a>() with a
number that identifies this particular accelerator item. Accelerator
items can also be individually connected, so that two different keys
will activate two different slots (see <a href="qaccel.html#b2">connectItem</a>()).
<p>A QAccel object handles key events to the
<a href="qwidget.html#e7">top level window</a>
containing <em>parent,</em> and hence to any child widgets of that window.
Note that the accelerator will be deleted only when the <em>parent</em>
is deleted, and will consume relevant key events until then.
<p>Example:
<pre> <a href="qaccel.html">QAccel</a> *a = new <a href="qaccel.html">QAccel</a>( myWindow ); // create accels for myWindow
a-><a href="qaccel.html#b2">connectItem</a>( a-><a href="qaccel.html#a5">insertItem</a>(Key_P+CTRL), // adds Ctrl+P accelerator
myWindow, // connected to myWindow's
SLOT(printDoc()) ); // printDoc() slot
</pre>
<p>See also: <a href="qkeyevent.html">QKeyEvent</a>, <a href="qwidget.html#n8">QWidget::keyPressEvent</a>(), <a href="qmenudata.html#c0">QMenuData::setAccel</a>(), <a href="qbutton.html#a7">QButton::setAccel</a>() and <a href="guibooks.html#fowler">GUI Design Handbook: Keyboard Shortcuts,</a>
<p>Examples:
<a href="application-application-cpp.html#QAccel">application/application.cpp</a>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="a0"></a>QAccel::QAccel(<a href="qwidget.html">QWidget</a>*parent, constchar*name=0)</h3>
<p>Creates a QAccel object with a parent widget and a name.
<h3 class="fn"><a name="a1"></a>QAccel::~QAccel()</h3>
<p>Destroys the accelerator object.
<h3 class="fn">void<a name="b5"></a>QAccel::activated(intid) <code>[signal]</code></h3>
<p>This signal is emitted when an accelerator key is pressed. <em>id</em> is
a number that identifies this particular accelerator item.
<h3 class="fn">void<a name="a7"></a>QAccel::clear()</h3>
<p>Removes all accelerator items.
<h3 class="fn">bool<a name="b2"></a>QAccel::connectItem(intid, const<a href="qobject.html">QObject</a>*receiver, constchar*member)</h3>
<p>Connects an accelerator item to a slot/signal in another object.
<p>Arguments:
<ul>
<li><em>id</em> is the accelerator item id.
<li><em>receiver</em> is the object to receive a signal.
<li><em>member</em> is a slot or signal function in the receiver.
</ul>
<pre> a->connectItem( 201, mainView, SLOT(quit()) );
</pre>
<p>See also: <a href="qaccel.html#b3">disconnectItem</a>().
<p>Examples:
<a href="application-application-cpp.html#connectItem">application/application.cpp</a>
<h3 class="fn">uint<a name="a4"></a>QAccel::count()const</h3>
<p>Returns the number of accelerator items.
<h3 class="fn">bool<a name="b3"></a>QAccel::disconnectItem(intid, const<a href="qobject.html">QObject</a>*receiver, constchar*member)</h3>
<p>Disconnects an accelerator item from a function in another
object.
<p>See also: <a href="qaccel.html#b2">connectItem</a>().
<h3 class="fn">bool<a name="b6"></a>QAccel::eventFilter(<a href="qobject.html">QObject</a>*, <a href="qevent.html">QEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Processes accelerator events intended for the top level widget.
<p>Reimplemented from <a href="qobject.html#a3">QObject.</a>
<h3 class="fn">int<a name="a9"></a>QAccel::findKey(intkey)const</h3>
<p>Returns the identifier of the accelerator item with the key code <em>key,</em> or
-1 if the item cannot be found.
<h3 class="fn">int<a name="a5"></a>QAccel::insertItem(intkey, intid=-1)</h3>
<p>Inserts an accelerator item and returns the item's identifier.
<p>Arguments:
<ul>
<li><em>key</em> is a key code plus a combination of SHIFT, CTRL and ALT.
<li><em>id</em> is the accelerator item id.
</ul>
If <em>id</em> is negative, then the item will be assigned a unique
identifier.
<p><pre> <a href="qaccel.html">QAccel</a> *a = new <a href="qaccel.html">QAccel</a>( myWindow ); // create accels for myWindow
a-><a href="qaccel.html#a5">insertItem</a>( Key_P + CTRL, 200 ); // Ctrl+P to print document
a-><a href="qaccel.html#a5">insertItem</a>( Key_X + ALT , 201 ); // Alt+X to quit
a-><a href="qaccel.html#a5">insertItem</a>( ASCII_ACCEL + 'q', 202 ); // ASCII 'q' to quit
a-><a href="qaccel.html#a5">insertItem</a>( Key_D ); // gets id 3
a-><a href="qaccel.html#a5">insertItem</a>( Key_P + CTRL + SHIFT ); // gets id 4
</pre>
<p>Examples:
<a href="application-application-cpp.html#insertItem">application/application.cpp</a>
<h3 class="fn">bool<a name="a2"></a>QAccel::isEnabled()const</h3>
<p>Returns TRUE if the accelerator is enabled, or FALSE if it is disabled.
<p>See also: <a href="qaccel.html#a3">setEnabled</a>() and <a href="qaccel.html#b0">isItemEnabled</a>().
<h3 class="fn">bool<a name="b0"></a>QAccel::isItemEnabled(intid)const</h3>
<p>Returns TRUE if the accelerator item with the identifier <em>id</em> is enabled.
Returns FALSE if the item is disabled or cannot be found.
<p>See also: <a href="qaccel.html#b1">setItemEnabled</a>() and <a href="qaccel.html#a2">isEnabled</a>().
<h3 class="fn">int<a name="a8"></a>QAccel::key(intid)</h3>
<p>Returns the key code of the accelerator item with the identifier <em>id,</em>
or zero if the id cannot be found.
<h3 class="fn">void<a name="a6"></a>QAccel::removeItem(intid)</h3>
<p>Removes the accelerator item with the identifier <em>id.</em>
<h3 class="fn">void<a name="b4"></a>QAccel::repairEventFilter()</h3>
<p>Make sure that the accelerator is watching the correct event
filter. Used by <a href="qwidget.html#l9">QWidget::recreate</a>().
<h3 class="fn">void<a name="a3"></a>QAccel::setEnabled(boolenable)</h3>
<p>Enables the accelerator if <em>enable</em> is TRUE, or disables it if
<em>enable</em> is FALSE.
<p>Individual keys can also be enabled or disabled.
<p>See also: <a href="qaccel.html#a2">isEnabled</a>() and <a href="qaccel.html#b1">setItemEnabled</a>().
<h3 class="fn">void<a name="b1"></a>QAccel::setItemEnabled(intid, boolenable)</h3>
<p>Enables or disables an accelerator item.
<p>Arguments:
<ul>
<li><em>id</em> is the item identifier.
<li><em>enable</em> specifies whether the item should be enabled or disabled.
</ul>
<p>See also: <a href="qaccel.html#b0">isItemEnabled</a>() and <a href="qaccel.html#a2">isEnabled</a>().
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.troll.no">www.troll.no</a>):<br>
<form method=post action="http://www.troll.no/search.cgi">
<input type=hidden name="version" value="1.44"><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-99
<a href="troll.html">Troll Tech</a>, all rights reserved.
<p>
It was generated from the following files:
<ul>
<li>qaccel.h: 1998/08/21
<li>qaccel.cpp: 1998/07/03
</ul>
<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 1999 Troll Tech<td><a href="trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 1.45</div>
</table></div></address></body></html>
|