source: trunk/doc/html/qkeysequence.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 11.6 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qkeysequence.cpp:56 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QKeySequence Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QKeySequence Class Reference</h1>
33
34<p>The QKeySequence class encapsulates a key sequence as used
35by accelerators.
36<a href="#details">More...</a>
37<p><tt>#include &lt;<a href="qkeysequence-h.html">qkeysequence.h</a>&gt;</tt>
38<p>Inherits <a href="qt.html">Qt</a>.
39<p><a href="qkeysequence-members.html">List of all member functions.</a>
40<h2>Public Members</h2>
41<ul>
42<li class=fn><a href="#QKeySequence"><b>QKeySequence</b></a> ()</li>
43<li class=fn><a href="#QKeySequence-2"><b>QKeySequence</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key )</li>
44<li class=fn><a href="#QKeySequence-3"><b>QKeySequence</b></a> ( int&nbsp;key )</li>
45<li class=fn><a href="#QKeySequence-4"><b>QKeySequence</b></a> ( int&nbsp;k1, int&nbsp;k2, int&nbsp;k3 = 0, int&nbsp;k4 = 0 )</li>
46<li class=fn><a href="#QKeySequence-5"><b>QKeySequence</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;keysequence )</li>
47<li class=fn><a href="#~QKeySequence"><b>~QKeySequence</b></a> ()</li>
48<li class=fn>uint <a href="#count"><b>count</b></a> () const</li>
49<li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li>
50<li class=fn>Qt::SequenceMatch <a href="#matches"><b>matches</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;seq ) const</li>
51<li class=fn><a href="#operator-QString"><b>operator QString</b></a> () const</li>
52<li class=fn>operator int () const &nbsp;<em>(obsolete)</em></li>
53<li class=fn>int <a href="#operator[]"><b>operator[]</b></a> ( uint&nbsp;index ) const</li>
54<li class=fn>QKeySequence &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;keysequence )</li>
55<li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;keysequence ) const</li>
56<li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;keysequence ) const</li>
57</ul>
58<h2>Related Functions</h2>
59<ul>
60<li class=fn>QDataStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, const&nbsp;QKeySequence&nbsp;&amp;&nbsp;keysequence )</li>
61<li class=fn>QDataStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QKeySequence&nbsp;&amp;&nbsp;keysequence )</li>
62</ul>
63<hr><a name="details"></a><h2>Detailed Description</h2>
64
65
66The QKeySequence class encapsulates a key sequence as used
67by accelerators.
68<p>
69<p> A key sequence consists of up to four keyboard codes, each
70optionally combined with modifiers, e.g. <a href="qt.html#Modifier-enum">SHIFT</a>, <a href="qt.html#Modifier-enum">CTRL</a>, <a href="qt.html#Modifier-enum">ALT</a>, <a href="qt.html#Modifier-enum">META</a>, or <a href="qt.html#Modifier-enum">UNICODE_ACCEL</a>. For example, <tt>CTRL + Key_P</tt>
71might be a sequence used as a shortcut for printing a document.
72The key codes are listed in <a href="qnamespace-h.html">qnamespace.h</a>. As an alternative,
73use <a href="qt.html#Modifier-enum">UNICODE_ACCEL</a> with the unicode code point of the character.
74For example, <tt>UNICODE_ACCEL + 'A'</tt> gives the same key sequence
75as <a href="qt.html#Key-enum">Key_A</a>.
76<p> Key sequences can be constructed either from an integer key code,
77or from a human readable translatable string such as
78"Ctrl+X,Alt+Space". A key sequence can be cast to a <a href="qstring.html">QString</a> to
79obtain a human readable translated version of the sequence.
80Translations are done in the "QAccel" context.
81<p> <p>See also <a href="qaccel.html">QAccel</a> and <a href="misc.html">Miscellaneous Classes</a>.
82
83<hr><h2>Member Function Documentation</h2>
84<h3 class=fn><a name="QKeySequence"></a>QKeySequence::QKeySequence ()
85</h3>
86Constructs an empty key sequence.
87
88<h3 class=fn><a name="QKeySequence-2"></a>QKeySequence::QKeySequence ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key )
89</h3>
90Creates a key sequence from the string <em>key</em>. For example
91"Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl",
92"Shift", "Alt" and "Meta" are recognized, as well as their
93translated equivalents in the "QAccel" context (using
94<a href="qobject.html#tr">QObject::tr</a>()).
95<p> Multiple key codes (up to four) may be entered by separating them
96with commas, e.g. "Alt+X,Ctrl+S,Q".
97<p> This contructor is typically used with <a href="qobject.html#tr">tr</a>(), so that accelerator keys can be replaced in
98translations:
99<p> <pre>
100 <a href="qpopupmenu.html">QPopupMenu</a> *file = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
101 file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( tr("&amp;Open..."), this, SLOT(open()),
102 <a href="#QKeySequence">QKeySequence</a>( tr("Ctrl+O", "File|Open") ) );
103 </pre>
104
105<p> Note the <tt>"File|Open"</tt> translator comment. It is by no means
106necessary, but it provides some context for the human translator.
107
108<h3 class=fn><a name="QKeySequence-3"></a>QKeySequence::QKeySequence ( int&nbsp;key )
109</h3>
110Constructs a key sequence that has a single <em>key</em>.
111<p> The key codes are listed in <a href="qnamespace-h.html">qnamespace.h</a> and can be
112combined with modifiers, e.g. with <a href="qt.html#Modifier-enum">SHIFT</a>, <a href="qt.html#Modifier-enum">CTRL</a>, <a href="qt.html#Modifier-enum">ALT</a>, <a href="qt.html#Modifier-enum">META</a> or <a href="qt.html#Modifier-enum">UNICODE_ACCEL</a>.
113
114<h3 class=fn><a name="QKeySequence-4"></a>QKeySequence::QKeySequence ( int&nbsp;k1, int&nbsp;k2, int&nbsp;k3 = 0, int&nbsp;k4 = 0 )
115</h3>
116Constructs a key sequence with up to 4 keys <em>k1</em>, <em>k2</em>,
117<em>k3</em> and <em>k4</em>.
118<p> The key codes are listed in <a href="qnamespace-h.html">qnamespace.h</a> and can be
119combined with modifiers, e.g. with <a href="qt.html#Modifier-enum">SHIFT</a>, <a href="qt.html#Modifier-enum">CTRL</a>, <a href="qt.html#Modifier-enum">ALT</a>, <a href="qt.html#Modifier-enum">META</a> or <a href="qt.html#Modifier-enum">UNICODE_ACCEL</a>.
120
121<h3 class=fn><a name="QKeySequence-5"></a>QKeySequence::QKeySequence ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;keysequence )
122</h3>
123Copy constructor. Makes a copy of <em>keysequence</em>.
124
125<h3 class=fn><a name="~QKeySequence"></a>QKeySequence::~QKeySequence ()
126</h3>
127Destroys the key sequence.
128
129<h3 class=fn>uint <a name="count"></a>QKeySequence::count () const
130</h3>
131Returns the number of keys in the key sequence.
132The maximum is 4.
133
134<h3 class=fn>bool <a name="isEmpty"></a>QKeySequence::isEmpty () const
135</h3>
136Returns TRUE if the key sequence is empty; otherwise returns
137FALSE.
138
139<h3 class=fn><a href="qt.html#SequenceMatch-enum">Qt::SequenceMatch</a> <a name="matches"></a>QKeySequence::matches ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;seq ) const
140</h3>
141Matches the sequence with <em>seq</em>. Returns <a href="qt.html#SequenceMatch-enum">Qt::Identical</a> if
142successful, <a href="qt.html#SequenceMatch-enum">Qt::PartialMatch</a> for matching but incomplete <em>seq</em>,
143and <a href="qt.html#SequenceMatch-enum">Qt::NoMatch</a> if the sequences have nothing in common.
144Returns <a href="qt.html#SequenceMatch-enum">Qt::NoMatch</a> if <em>seq</em> is shorter.
145
146<h3 class=fn><a name="operator-QString"></a>QKeySequence::operator QString () const
147</h3>
148Creates an accelerator string for the key sequence.
149For instance CTRL+Key_O gives "Ctrl+O". If the key sequence has
150multiple key codes they are returned comma-separated, e.g.
151"Alt+X, Ctrl+Y, Z". The strings, "Ctrl", "Shift", etc. are
152translated (using <a href="qobject.html#tr">QObject::tr</a>()) in the "QAccel" scope. If the key
153sequence has no keys, <a href="qstring.html#QString-null">QString::null</a> is returned.
154<p> On Mac OS X, the string returned resembles the sequence that is shown in
155the menubar.
156
157<h3 class=fn><a name="operator-int"></a>QKeySequence::operator int () const
158</h3>
159<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
160<p> For backward compatibility: returns the first keycode
161as integer. If the key sequence is empty, 0 is returned.
162
163<h3 class=fn>bool <a name="operator!-eq"></a>QKeySequence::operator!= ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;keysequence ) const
164</h3>
165Returns TRUE if <em>keysequence</em> is not equal to this key sequence;
166otherwise returns FALSE.
167
168<h3 class=fn><a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp; <a name="operator-eq"></a>QKeySequence::operator= ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;keysequence )
169</h3>
170Assignment operator. Assigns <em>keysequence</em> to this
171object.
172
173<h3 class=fn>bool <a name="operator-eq-eq"></a>QKeySequence::operator== ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;keysequence ) const
174</h3>
175Returns TRUE if <em>keysequence</em> is equal to this key
176sequence; otherwise returns FALSE.
177
178<h3 class=fn>int <a name="operator[]"></a>QKeySequence::operator[] ( uint&nbsp;index ) const
179</h3>
180Returns a reference to the element at position <em>index</em> in the key
181sequence. This can only be used to read an element.
182
183<hr><h2>Related Functions</h2>
184<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-lt-lt"></a>operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;keysequence )
185</h3>
186
187<p> Writes the key sequence <em>keysequence</em> to the stream <em>s</em>.
188<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
189
190<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-gt-gt"></a>operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, <a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;keysequence )
191</h3>
192
193<p> Reads a key sequence from the stream <em>s</em> into the key sequence <em>keysequence</em>.
194<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
195
196<!-- eof -->
197<hr><p>
198This file is part of the <a href="index.html">Qt toolkit</a>.
199Copyright &copy; 1995-2007
200<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
201<table width=100% cellspacing=0 border=0><tr>
202<td>Copyright &copy; 2007
203<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
204<td align=right><div align=right>Qt 3.3.8</div>
205</table></div></address></body>
206</html>
Note: See TracBrowser for help on using the repository browser.