[190] | 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/qaccel.cpp:51 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QAccel Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { 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 Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main 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 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>QAccel Class Reference</h1>
|
---|
| 33 |
|
---|
| 34 | <p>The QAccel class handles keyboard accelerator and shortcut keys.
|
---|
| 35 | <a href="#details">More...</a>
|
---|
| 36 | <p><tt>#include <<a href="qaccel-h.html">qaccel.h</a>></tt>
|
---|
| 37 | <p>Inherits <a href="qobject.html">QObject</a>.
|
---|
| 38 | <p><a href="qaccel-members.html">List of all member functions.</a>
|
---|
| 39 | <h2>Public Members</h2>
|
---|
| 40 | <ul>
|
---|
| 41 | <li class=fn><a href="#QAccel"><b>QAccel</b></a> ( QWidget * parent, const char * name = 0 )</li>
|
---|
| 42 | <li class=fn><a href="#QAccel-2"><b>QAccel</b></a> ( QWidget * watch, QObject * parent, const char * name = 0 )</li>
|
---|
| 43 | <li class=fn><a href="#~QAccel"><b>~QAccel</b></a> ()</li>
|
---|
| 44 | <li class=fn>bool <a href="#isEnabled"><b>isEnabled</b></a> () const</li>
|
---|
| 45 | <li class=fn>void <a href="#setEnabled"><b>setEnabled</b></a> ( bool enable )</li>
|
---|
| 46 | <li class=fn>uint <a href="#count"><b>count</b></a> () const</li>
|
---|
| 47 | <li class=fn>int <a href="#insertItem"><b>insertItem</b></a> ( const QKeySequence & key, int id = -1 )</li>
|
---|
| 48 | <li class=fn>void <a href="#removeItem"><b>removeItem</b></a> ( int id )</li>
|
---|
| 49 | <li class=fn>void <a href="#clear"><b>clear</b></a> ()</li>
|
---|
| 50 | <li class=fn>QKeySequence <a href="#key"><b>key</b></a> ( int id )</li>
|
---|
| 51 | <li class=fn>int <a href="#findKey"><b>findKey</b></a> ( const QKeySequence & key ) const</li>
|
---|
| 52 | <li class=fn>bool <a href="#isItemEnabled"><b>isItemEnabled</b></a> ( int id ) const</li>
|
---|
| 53 | <li class=fn>void <a href="#setItemEnabled"><b>setItemEnabled</b></a> ( int id, bool enable )</li>
|
---|
| 54 | <li class=fn>bool <a href="#connectItem"><b>connectItem</b></a> ( int id, const QObject * receiver, const char * member )</li>
|
---|
| 55 | <li class=fn>bool <a href="#disconnectItem"><b>disconnectItem</b></a> ( int id, const QObject * receiver, const char * member )</li>
|
---|
| 56 | <li class=fn>void repairEventFilter () <em>(obsolete)</em></li>
|
---|
| 57 | <li class=fn>void <a href="#setWhatsThis"><b>setWhatsThis</b></a> ( int id, const QString & text )</li>
|
---|
| 58 | <li class=fn>QString <a href="#whatsThis"><b>whatsThis</b></a> ( int id ) const</li>
|
---|
| 59 | </ul>
|
---|
| 60 | <h2>Signals</h2>
|
---|
| 61 | <ul>
|
---|
| 62 | <li class=fn>void <a href="#activated"><b>activated</b></a> ( int id )</li>
|
---|
| 63 | <li class=fn>void <a href="#activatedAmbiguously"><b>activatedAmbiguously</b></a> ( int id )</li>
|
---|
| 64 | </ul>
|
---|
| 65 | <h2>Static Public Members</h2>
|
---|
| 66 | <ul>
|
---|
| 67 | <li class=fn>QKeySequence <a href="#shortcutKey"><b>shortcutKey</b></a> ( const QString & str )</li>
|
---|
| 68 | <li class=fn>QString keyToString ( QKeySequence k ) <em>(obsolete)</em></li>
|
---|
| 69 | <li class=fn>QKeySequence stringToKey ( const QString & s ) <em>(obsolete)</em></li>
|
---|
| 70 | </ul>
|
---|
| 71 | <h2>Protected Members</h2>
|
---|
| 72 | <ul>
|
---|
| 73 | <li class=fn>virtual bool eventFilter ( QObject *, QEvent * ) <em>(obsolete)</em></li>
|
---|
| 74 | </ul>
|
---|
| 75 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 | The QAccel class handles keyboard accelerator and shortcut keys.
|
---|
| 79 | <p>
|
---|
| 80 | <p> A keyboard accelerator triggers an action when a certain key
|
---|
| 81 | combination is pressed. The accelerator handles all keyboard
|
---|
| 82 | activity for all the children of one top-level widget, so it is
|
---|
| 83 | not affected by the <a href="focus.html#keyboard-focus">keyboard focus</a>.
|
---|
| 84 | <p> In most cases, you will not need to use this class directly. Use
|
---|
| 85 | the <a href="qaction.html">QAction</a> class to create actions with accelerators that can be
|
---|
| 86 | used in both menus and toolbars. If you're only interested in
|
---|
| 87 | menus use <a href="qmenudata.html#insertItem">QMenuData::insertItem</a>() or <a href="qmenudata.html#setAccel">QMenuData::setAccel</a>() to make
|
---|
| 88 | accelerators for operations that are also available on menus. Many
|
---|
| 89 | widgets automatically generate accelerators, such as <a href="qbutton.html">QButton</a>,
|
---|
| 90 | <a href="qgroupbox.html">QGroupBox</a>, <a href="qlabel.html">QLabel</a> (with <a href="qlabel.html#setBuddy">QLabel::setBuddy</a>()), <a href="qmenubar.html">QMenuBar</a> and <a href="qtabbar.html">QTabBar</a>.
|
---|
| 91 | Example:
|
---|
| 92 | <pre>
|
---|
| 93 | <a href="qpushbutton.html">QPushButton</a> p( "&Exit", parent ); // automatic shortcut ALT+Key_E
|
---|
| 94 | <a href="qpopupmenu.html">QPopupMenu</a> *fileMenu = new fileMenu( parent );
|
---|
| 95 | fileMenu-><a href="qmenudata.html#insertItem">insertItem</a>( "Undo", parent, SLOT(undo()), CTRL+Key_Z );
|
---|
| 96 | </pre>
|
---|
| 97 |
|
---|
| 98 | <p> A QAccel contains a list of accelerator items that can be
|
---|
| 99 | manipulated using <a href="#insertItem">insertItem</a>(), <a href="#removeItem">removeItem</a>(), <a href="#clear">clear</a>(), <a href="#key">key</a>() and
|
---|
| 100 | <a href="#findKey">findKey</a>().
|
---|
| 101 | <p> Each accelerator item consists of an identifier and a <a href="qkeysequence.html">QKeySequence</a>. A single key sequence consists of a keyboard code
|
---|
| 102 | combined with modifiers (<a href="qt.html#Modifier-enum">SHIFT</a>, <a href="qt.html#Modifier-enum">CTRL</a>, <a href="qt.html#Modifier-enum">ALT</a> or <a href="qt.html#Modifier-enum">UNICODE_ACCEL</a>). For example, <tt>CTRL + Key_P</tt> could be a shortcut
|
---|
| 103 | for printing a document. The key codes are listed in <a href="qnamespace-h.html">qnamespace.h</a>. As an alternative, use <a href="qt.html#Modifier-enum">UNICODE_ACCEL</a> with the
|
---|
| 104 | unicode code point of the character. For example, <tt>UNICODE_ACCEL + 'A'</tt> gives the same accelerator as <a href="qt.html#Key-enum">Key_A</a>.
|
---|
| 105 | <p> When an accelerator key is pressed, the accelerator sends out the
|
---|
| 106 | signal <a href="#activated">activated</a>() with a number that identifies this particular
|
---|
| 107 | accelerator item. Accelerator items can also be individually
|
---|
| 108 | connected, so that two different keys will activate two different
|
---|
| 109 | slots (see <a href="#connectItem">connectItem</a>() and <a href="#disconnectItem">disconnectItem</a>()).
|
---|
| 110 | <p> The activated() signal is <em>not</em> emitted when two or more
|
---|
| 111 | accelerators match the same key. Instead, the first matching
|
---|
| 112 | accelerator sends out the <a href="#activatedAmbiguously">activatedAmbiguously</a>() signal. By
|
---|
| 113 | pressing the key multiple times, users can navigate between all
|
---|
| 114 | matching accelerators. Some standard controls like <a href="qpushbutton.html">QPushButton</a> and
|
---|
| 115 | <a href="qcheckbox.html">QCheckBox</a> connect the activatedAmbiguously() signal to the
|
---|
| 116 | harmless setFocus() slot, whereas activated() is connected to a
|
---|
| 117 | slot invoking the button's action. Most controls, like <a href="qlabel.html">QLabel</a> and
|
---|
| 118 | <a href="qtabbar.html">QTabBar</a>, treat activated() and activatedAmbiguously() as
|
---|
| 119 | equivalent.
|
---|
| 120 | <p> Use <a href="#setEnabled">setEnabled</a>() to enable or disable all the items in an
|
---|
| 121 | accelerator, or <a href="#setItemEnabled">setItemEnabled</a>() to enable or disable individual
|
---|
| 122 | items. An item is active only when both the QAccel and the item
|
---|
| 123 | itself are enabled.
|
---|
| 124 | <p> The function <a href="#setWhatsThis">setWhatsThis</a>() specifies a help text that appears
|
---|
| 125 | when the user presses an accelerator key in What's This mode.
|
---|
| 126 | <p> The accelerator will be deleted when <em>parent</em> is deleted,
|
---|
| 127 | and will consume relevant key events until then.
|
---|
| 128 | <p> Please note that the accelerator
|
---|
| 129 | <pre>
|
---|
| 130 | accelerator->insertItem( QKeySequence("M") );
|
---|
| 131 | </pre>
|
---|
| 132 |
|
---|
| 133 | can be triggered with both the 'M' key, and with Shift+M,
|
---|
| 134 | unless a second accelerator is defined for the Shift+M
|
---|
| 135 | combination.
|
---|
| 136 | <p> Example:
|
---|
| 137 | <pre>
|
---|
| 138 | QAccel *a = new QAccel( myWindow ); // create accels for myWindow
|
---|
| 139 | a-><a href="#connectItem">connectItem</a>( a-><a href="#insertItem">insertItem</a>(Key_P+CTRL), // adds Ctrl+P accelerator
|
---|
| 140 | myWindow, // connected to myWindow's
|
---|
| 141 | SLOT(printDoc()) ); // printDoc() slot
|
---|
| 142 | </pre>
|
---|
| 143 |
|
---|
| 144 | <p> <p>See also <a href="qkeyevent.html">QKeyEvent</a>, <a href="qwidget.html#keyPressEvent">QWidget::keyPressEvent</a>(), <a href="qmenudata.html#setAccel">QMenuData::setAccel</a>(), <a href="qbutton.html#accel-prop">QButton::accel</a>, <a href="qlabel.html#setBuddy">QLabel::setBuddy</a>(), <a href="qkeysequence.html">QKeySequence</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Keyboard Shortcuts</a>, and <a href="misc.html">Miscellaneous Classes</a>.
|
---|
| 145 |
|
---|
| 146 | <hr><h2>Member Function Documentation</h2>
|
---|
| 147 | <h3 class=fn><a name="QAccel"></a>QAccel::QAccel ( <a href="qwidget.html">QWidget</a> * parent, const char * name = 0 )
|
---|
| 148 | </h3>
|
---|
| 149 | Constructs a QAccel object called <em>name</em>, with parent <em>parent</em>.
|
---|
| 150 | The accelerator operates on <em>parent</em>.
|
---|
| 151 |
|
---|
| 152 | <h3 class=fn><a name="QAccel-2"></a>QAccel::QAccel ( <a href="qwidget.html">QWidget</a> * watch, <a href="qobject.html">QObject</a> * parent, const char * name = 0 )
|
---|
| 153 | </h3>
|
---|
| 154 | Constructs a QAccel object called <em>name</em>, that operates on <em>watch</em>, and is a child of <em>parent</em>.
|
---|
| 155 | <p> This constructor is not needed for normal application programming.
|
---|
| 156 |
|
---|
| 157 | <h3 class=fn><a name="~QAccel"></a>QAccel::~QAccel ()
|
---|
| 158 | </h3>
|
---|
| 159 | Destroys the accelerator object and frees all allocated resources.
|
---|
| 160 |
|
---|
| 161 | <h3 class=fn>void <a name="activated"></a>QAccel::activated ( int id )<tt> [signal]</tt>
|
---|
| 162 | </h3>
|
---|
| 163 |
|
---|
| 164 | <p> This signal is emitted when an accelerator key is pressed. <em>id</em>
|
---|
| 165 | is a number that identifies this particular accelerator item.
|
---|
| 166 | <p> <p>See also <a href="#activatedAmbiguously">activatedAmbiguously</a>().
|
---|
| 167 |
|
---|
| 168 | <h3 class=fn>void <a name="activatedAmbiguously"></a>QAccel::activatedAmbiguously ( int id )<tt> [signal]</tt>
|
---|
| 169 | </h3>
|
---|
| 170 |
|
---|
| 171 | <p> This signal is emitted when an accelerator key is pressed. <em>id</em>
|
---|
| 172 | is a number that identifies this particular accelerator item.
|
---|
| 173 | <p> <p>See also <a href="#activated">activated</a>().
|
---|
| 174 |
|
---|
| 175 | <h3 class=fn>void <a name="clear"></a>QAccel::clear ()
|
---|
| 176 | </h3>
|
---|
| 177 | Removes all accelerator items.
|
---|
| 178 |
|
---|
| 179 | <h3 class=fn>bool <a name="connectItem"></a>QAccel::connectItem ( int id, const <a href="qobject.html">QObject</a> * receiver, const char * member )
|
---|
| 180 | </h3>
|
---|
| 181 | Connects the accelerator item <em>id</em> to the slot <em>member</em> of <em>receiver</em>.
|
---|
| 182 | <p> <pre>
|
---|
| 183 | a->connectItem( 201, mainView, SLOT(quit()) );
|
---|
| 184 | </pre>
|
---|
| 185 |
|
---|
| 186 | <p> Of course, you can also send a signal as <em>member</em>.
|
---|
| 187 | <p> Normally accelerators are connected to slots which then receive
|
---|
| 188 | the <tt>activated(int id)</tt> signal with the id of the accelerator
|
---|
| 189 | item that was activated. If you choose to connect a specific
|
---|
| 190 | accelerator item using this function, the <a href="#activated">activated</a>() signal is
|
---|
| 191 | emitted if the associated key sequence is pressed but no <tt>activated(int id)</tt> signal is emitted.
|
---|
| 192 | <p> <p>See also <a href="#disconnectItem">disconnectItem</a>().
|
---|
| 193 |
|
---|
| 194 | <p>Example: <a href="tutorial1-14.html#x2437">t14/gamebrd.cpp</a>.
|
---|
| 195 | <h3 class=fn>uint <a name="count"></a>QAccel::count () const
|
---|
| 196 | </h3>
|
---|
| 197 | Returns the number of accelerator items in this accelerator.
|
---|
| 198 |
|
---|
| 199 | <h3 class=fn>bool <a name="disconnectItem"></a>QAccel::disconnectItem ( int id, const <a href="qobject.html">QObject</a> * receiver, const char * member )
|
---|
| 200 | </h3>
|
---|
| 201 | Disconnects an accelerator item with id <em>id</em> from the function
|
---|
| 202 | called <em>member</em> in the <em>receiver</em> object.
|
---|
| 203 | <p> <p>See also <a href="#connectItem">connectItem</a>().
|
---|
| 204 |
|
---|
| 205 | <h3 class=fn>bool <a name="eventFilter"></a>QAccel::eventFilter ( <a href="qobject.html">QObject</a> *, <a href="qevent.html">QEvent</a> * )<tt> [virtual protected]</tt>
|
---|
| 206 | </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 207 | serves no purpose anymore
|
---|
| 208 | <p>Reimplemented from <a href="qobject.html#eventFilter">QObject</a>.
|
---|
| 209 | <h3 class=fn>int <a name="findKey"></a>QAccel::findKey ( const <a href="qkeysequence.html">QKeySequence</a> & key ) const
|
---|
| 210 | </h3>
|
---|
| 211 | Returns the identifier of the accelerator item with the key code
|
---|
| 212 | <em>key</em>, or -1 if the item cannot be found.
|
---|
| 213 |
|
---|
| 214 | <h3 class=fn>int <a name="insertItem"></a>QAccel::insertItem ( const <a href="qkeysequence.html">QKeySequence</a> & key, int id = -1 )
|
---|
| 215 | </h3>
|
---|
| 216 | Inserts an accelerator item and returns the item's identifier.
|
---|
| 217 | <p> <em>key</em> is a key code and an optional combination of SHIFT, CTRL
|
---|
| 218 | and ALT. <em>id</em> is the accelerator item id.
|
---|
| 219 | <p> If <em>id</em> is negative, then the item will be assigned a unique
|
---|
| 220 | negative identifier less than -1.
|
---|
| 221 | <p> <pre>
|
---|
| 222 | QAccel *a = new QAccel( myWindow ); // create accels for myWindow
|
---|
| 223 | a-><a href="#insertItem">insertItem</a>( CTRL + Key_P, 200 ); // Ctrl+P, e.g. to print document
|
---|
| 224 | a-><a href="#insertItem">insertItem</a>( ALT + Key_X, 201 ); // Alt+X, e.g. to quit
|
---|
| 225 | a-><a href="#insertItem">insertItem</a>( UNICODE_ACCEL + 'q', 202 ); // Unicode 'q', e.g. to quit
|
---|
| 226 | a-><a href="#insertItem">insertItem</a>( <a href="qt.html#Key-enum">Key_D</a> ); // gets a unique negative id < -1
|
---|
| 227 | a-><a href="#insertItem">insertItem</a>( CTRL + SHIFT + Key_P ); // gets a unique negative id < -1
|
---|
| 228 | </pre>
|
---|
| 229 |
|
---|
| 230 |
|
---|
| 231 | <p>Example: <a href="tutorial1-14.html#x2438">t14/gamebrd.cpp</a>.
|
---|
| 232 | <h3 class=fn>bool <a name="isEnabled"></a>QAccel::isEnabled () const
|
---|
| 233 | </h3>
|
---|
| 234 | Returns TRUE if the accelerator is enabled; otherwise returns
|
---|
| 235 | FALSE.
|
---|
| 236 | <p> <p>See also <a href="#setEnabled">setEnabled</a>() and <a href="#isItemEnabled">isItemEnabled</a>().
|
---|
| 237 |
|
---|
| 238 | <h3 class=fn>bool <a name="isItemEnabled"></a>QAccel::isItemEnabled ( int id ) const
|
---|
| 239 | </h3>
|
---|
| 240 | Returns TRUE if the accelerator item with the identifier <em>id</em> is
|
---|
| 241 | enabled. Returns FALSE if the item is disabled or cannot be found.
|
---|
| 242 | <p> <p>See also <a href="#setItemEnabled">setItemEnabled</a>() and <a href="#isEnabled">isEnabled</a>().
|
---|
| 243 |
|
---|
| 244 | <h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="key"></a>QAccel::key ( int id )
|
---|
| 245 | </h3>
|
---|
| 246 | Returns the key sequence of the accelerator item with identifier
|
---|
| 247 | <em>id</em>, or an invalid key sequence (0) if the id cannot be found.
|
---|
| 248 |
|
---|
| 249 | <h3 class=fn><a href="qstring.html">QString</a> <a name="keyToString"></a>QAccel::keyToString ( <a href="qkeysequence.html">QKeySequence</a> k )<tt> [static]</tt>
|
---|
| 250 | </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 251 | <p> Creates an accelerator string for the key <em>k</em>.
|
---|
| 252 | For instance CTRL+Key_O gives "Ctrl+O". The "Ctrl" etc.
|
---|
| 253 | are translated (using <a href="qobject.html#tr">QObject::tr</a>()) in the "QAccel" context.
|
---|
| 254 | <p> The function is superfluous. Cast the <a href="qkeysequence.html">QKeySequence</a> <em>k</em> to a
|
---|
| 255 | <a href="qstring.html">QString</a> for the same effect.
|
---|
| 256 |
|
---|
| 257 | <h3 class=fn>void <a name="removeItem"></a>QAccel::removeItem ( int id )
|
---|
| 258 | </h3>
|
---|
| 259 | Removes the accelerator item with the identifier <em>id</em>.
|
---|
| 260 |
|
---|
| 261 | <h3 class=fn>void <a name="repairEventFilter"></a>QAccel::repairEventFilter ()
|
---|
| 262 | </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 263 | serves no purpose anymore
|
---|
| 264 | <h3 class=fn>void <a name="setEnabled"></a>QAccel::setEnabled ( bool enable )
|
---|
| 265 | </h3>
|
---|
| 266 | Enables the accelerator if <em>enable</em> is TRUE, or disables it if <em>enable</em> is FALSE.
|
---|
| 267 | <p> Individual keys can also be enabled or disabled using
|
---|
| 268 | <a href="#setItemEnabled">setItemEnabled</a>(). To work, a key must be an enabled item in an
|
---|
| 269 | enabled QAccel.
|
---|
| 270 | <p> <p>See also <a href="#isEnabled">isEnabled</a>() and <a href="#setItemEnabled">setItemEnabled</a>().
|
---|
| 271 |
|
---|
| 272 | <h3 class=fn>void <a name="setItemEnabled"></a>QAccel::setItemEnabled ( int id, bool enable )
|
---|
| 273 | </h3>
|
---|
| 274 | Enables the accelerator item with the identifier <em>id</em> if <em>enable</em> is TRUE, and disables item <em>id</em> if <em>enable</em> is FALSE.
|
---|
| 275 | <p> To work, an item must be enabled and be in an enabled QAccel.
|
---|
| 276 | <p> <p>See also <a href="#isItemEnabled">isItemEnabled</a>() and <a href="#isEnabled">isEnabled</a>().
|
---|
| 277 |
|
---|
| 278 | <h3 class=fn>void <a name="setWhatsThis"></a>QAccel::setWhatsThis ( int id, const <a href="qstring.html">QString</a> & text )
|
---|
| 279 | </h3>
|
---|
| 280 | Sets a What's This help text for the accelerator item <em>id</em> to <em>text</em>.
|
---|
| 281 | <p> The text will be shown when the application is in What's This mode
|
---|
| 282 | and the user hits the accelerator key.
|
---|
| 283 | <p> To set What's This help on a menu item (with or without an
|
---|
| 284 | accelerator key), use <a href="qmenudata.html#setWhatsThis">QMenuData::setWhatsThis</a>().
|
---|
| 285 | <p> <p>See also <a href="#whatsThis">whatsThis</a>(), <a href="qwhatsthis.html#inWhatsThisMode">QWhatsThis::inWhatsThisMode</a>(), <a href="qmenudata.html#setWhatsThis">QMenuData::setWhatsThis</a>(), and <a href="qaction.html#whatsThis-prop">QAction::whatsThis</a>.
|
---|
| 286 |
|
---|
| 287 | <h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="shortcutKey"></a>QAccel::shortcutKey ( const <a href="qstring.html">QString</a> & str )<tt> [static]</tt>
|
---|
| 288 | </h3>
|
---|
| 289 | Returns the shortcut key sequence for <em>str</em>, or an invalid key
|
---|
| 290 | sequence (0) if <em>str</em> has no shortcut sequence.
|
---|
| 291 | <p> For example, <a href="#shortcutKey">shortcutKey</a>("E&xit") returns ALT+Key_X,
|
---|
| 292 | shortcutKey("&Quit") returns ALT+Key_Q and shortcutKey("Quit")
|
---|
| 293 | returns 0. (In code that does not inherit the Qt namespace class,
|
---|
| 294 | you must write e.g. Qt::ALT+Qt::Key_Q.)
|
---|
| 295 | <p> We provide a <a href="accelerators.html">list of common accelerators</a> in English. At the time of writing, Microsoft and Open
|
---|
| 296 | Group do not appear to have issued equivalent recommendations for
|
---|
| 297 | other languages.
|
---|
| 298 |
|
---|
| 299 | <h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="stringToKey"></a>QAccel::stringToKey ( const <a href="qstring.html">QString</a> & s )<tt> [static]</tt>
|
---|
| 300 | </h3><b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 301 | <p> Returns an accelerator code for the string <em>s</em>. For example
|
---|
| 302 | "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl",
|
---|
| 303 | "Shift", "Alt" are recognized, as well as their translated
|
---|
| 304 | equivalents in the "QAccel" context (using <a href="qobject.html#tr">QObject::tr</a>()). Returns 0
|
---|
| 305 | if <em>s</em> is not recognized.
|
---|
| 306 | <p> This function is typically used with <a href="qobject.html#tr">tr</a>(), so that accelerator keys can be replaced in
|
---|
| 307 | translations:
|
---|
| 308 | <p> <pre>
|
---|
| 309 | <a href="qpopupmenu.html">QPopupMenu</a> *file = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
|
---|
| 310 | file-><a href="qmenudata.html#insertItem">insertItem</a>( p1, tr("&Open..."), this, SLOT(open()),
|
---|
| 311 | QAccel::<a href="#stringToKey">stringToKey</a>(<a href="qobject.html#tr">tr</a>("Ctrl+O", "File|Open")) );
|
---|
| 312 | </pre>
|
---|
| 313 |
|
---|
| 314 | <p> Notice the <tt>"File|Open"</tt> translator comment. It is by no means
|
---|
| 315 | necessary, but it provides some context for the human translator.
|
---|
| 316 | <p> The function is superfluous. Construct a <a href="qkeysequence.html">QKeySequence</a> from the
|
---|
| 317 | string <em>s</em> for the same effect.
|
---|
| 318 | <p> <p>See also <a href="qobject.html#tr">QObject::tr</a>() and <a href="i18n.html">Internationalization with Qt</a>.
|
---|
| 319 |
|
---|
| 320 | <p>Example: <a href="i18n-example.html#x1921">i18n/mywidget.cpp</a>.
|
---|
| 321 | <h3 class=fn><a href="qstring.html">QString</a> <a name="whatsThis"></a>QAccel::whatsThis ( int id ) const
|
---|
| 322 | </h3>
|
---|
| 323 | Returns the What's This help text for the specified item <em>id</em> or
|
---|
| 324 | <a href="qstring.html#QString-null">QString::null</a> if no text has been specified.
|
---|
| 325 | <p> <p>See also <a href="#setWhatsThis">setWhatsThis</a>().
|
---|
| 326 |
|
---|
| 327 | <!-- eof -->
|
---|
| 328 | <hr><p>
|
---|
| 329 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 330 | Copyright © 1995-2007
|
---|
| 331 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 332 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 333 | <td>Copyright © 2007
|
---|
| 334 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 335 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 336 | </table></div></address></body>
|
---|
| 337 | </html>
|
---|