Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 841

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/kernel/qaccel.cpp:49 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QAccel 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: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<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>

<p>The QAccel class handles keyboard accelerator and shortcut keys.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qaccel-h.html">qaccel.h</a>&gt;</tt>
<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><div class=fn><a href="#QAccel"><b>QAccel</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</div></li>
<li><div class=fn><a href="#QAccel-2"><b>QAccel</b></a> ( QWidget&nbsp;*&nbsp;watch, QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</div></li>
<li><div class=fn><a href="#~QAccel"><b>~QAccel</b></a> ()</div></li>
<li><div class=fn>bool <a href="#isEnabled"><b>isEnabled</b></a> () const</div></li>
<li><div class=fn>void <a href="#setEnabled"><b>setEnabled</b></a> ( bool&nbsp;enable )</div></li>
<li><div class=fn>uint <a href="#count"><b>count</b></a> () const</div></li>
<li><div class=fn>int <a href="#insertItem"><b>insertItem</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;key, int&nbsp;id = -1 )</div></li>
<li><div class=fn>void <a href="#removeItem"><b>removeItem</b></a> ( int&nbsp;id )</div></li>
<li><div class=fn>void <a href="#clear"><b>clear</b></a> ()</div></li>
<li><div class=fn>QKeySequence <a href="#key"><b>key</b></a> ( int&nbsp;id )</div></li>
<li><div class=fn>int <a href="#findKey"><b>findKey</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;key ) const</div></li>
<li><div class=fn>bool <a href="#isItemEnabled"><b>isItemEnabled</b></a> ( int&nbsp;id ) const</div></li>
<li><div class=fn>void <a href="#setItemEnabled"><b>setItemEnabled</b></a> ( int&nbsp;id, bool&nbsp;enable )</div></li>
<li><div class=fn>bool <a href="#connectItem"><b>connectItem</b></a> ( int&nbsp;id, const&nbsp;QObject&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member )</div></li>
<li><div class=fn>bool <a href="#disconnectItem"><b>disconnectItem</b></a> ( int&nbsp;id, const&nbsp;QObject&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member )</div></li>
<li><div class=fn>void <a href="#repairEventFilter"><b>repairEventFilter</b></a> ()</div></li>
<li><div class=fn>void <a href="#setWhatsThis"><b>setWhatsThis</b></a> ( int&nbsp;id, const&nbsp;QString&nbsp;&amp;&nbsp;text )</div></li>
<li><div class=fn>QString <a href="#whatsThis"><b>whatsThis</b></a> ( int&nbsp;id ) const</div></li>
</ul>
<h2>Signals</h2>
<ul>
<li><div class=fn>void <a href="#activated"><b>activated</b></a> ( int&nbsp;id )</div></li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class=fn>QKeySequence <a href="#shortcutKey"><b>shortcutKey</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;str )</div></li>
<li><div class=fn>QString keyToString ( QKeySequence&nbsp;k ) &nbsp;<em>(obsolete)</em></div></li>
<li><div class=fn>QKeySequence stringToKey ( const&nbsp;QString&nbsp;&amp;&nbsp;s ) &nbsp;<em>(obsolete)</em></div></li>
</ul>
<h2>Protected Members</h2>
<ul>
<li><div class=fn>virtual bool <a href="#eventFilter"><b>eventFilter</b></a> ( QObject&nbsp;*&nbsp;o, QEvent&nbsp;*&nbsp;e )</div></li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QAccel class handles keyboard accelerator and shortcut keys.
<p> 
<p> A keyboard accelerator triggers an action when a certain key
combination is pressed. The accelerator handles all keyboard
activity for all the children of one top-level widget, so it is not
affected by the <a href="focus.html#keyboard-focus">keyboard focus</a>.
<p> In most cases, you will not need to use this class directly. Use the
<a href="qaction.html">QAction</a> class to create actions with accelerators that can be used in
both menus and toolbars. If you're only interested in menus use
<a href="qmenudata.html#insertItem">QMenuData::insertItem</a>() or <a href="qmenudata.html#setAccel">QMenuData::setAccel</a>() to make accelerators
for operations that are also available on menus.  Many widgets
automatically generate accelerators, such as <a href="qbutton.html">QButton</a>, <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>.
Example:
<pre>
     <a href="qpushbutton.html">QPushButton</a> p( "&amp;Exit", parent ); // automatic shortcut ALT+Key_E
     <a href="qpopupmenu.html">QPopupMenu</a> *fileMenu = new fileMenu( parent );
     fileMenu-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Undo", parent, SLOT(undo()), CTRL+Key_Z );
  </pre>
 
<p> A QAccel contains a list of accelerator items that can be
manipulated using <a href="#insertItem">insertItem</a>(), <a href="#removeItem">removeItem</a>(), <a href="#clear">clear</a>(),
<a href="#key">key</a>() and <a href="#findKey">findKey</a>().
<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
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 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
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>.
<p> When an accelerator key is pressed, the accelerator sends out the
signal <a href="#activated">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="#connectItem">connectItem</a>() and <a href="#disconnectItem">disconnectItem</a>()).
<p> Use <a href="#setEnabled">setEnabled</a>() to enable/disable all items in the accelerator, or
<a href="#setItemEnabled">setItemEnabled</a>() to enable/disable individual items.  An item is
active only when both the QAccel and the item itself are enabled.
<p> The function <a href="#setWhatsThis">setWhatsThis</a>() specifies a help text that appears when
the user presses an accelerator key in What's This mode.
<p> A QAccel object passes key events to the <a href="qwidget.html#topLevelWidget">QWidget::topLevelWidget</a>()
containing <em>parent</em>, and hence to any child widgets of that window.
The accelerator will be deleted when <em>parent</em> is deleted, and will
consume relevant key events until then.
<p> Example:
<pre>
     QAccel *a = new QAccel( myWindow );        // create accels for myWindow
     a-&gt;<a href="#connectItem">connectItem</a>( a-&gt;<a href="#insertItem">insertItem</a>(Key_P+CTRL), // adds Ctrl+P accelerator
                     myWindow,                  // connected to myWindow's
                     SLOT(printDoc()) );        // printDoc() slot
  </pre>
 
<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>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QAccel"></a>QAccel::QAccel ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Constructs a QAccel object with parent <em>parent</em> and name <em>name</em>. The
accelerator operates on <em>parent</em>.

<h3 class=fn><a name="QAccel-2"></a>QAccel::QAccel ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;watch, <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Constructs a QAccel object that operates on <em>watch</em>, but is a child of
<em>parent</em>. The object is called <em>name</em>.
<p> This constructor is not needed for normal application programming.

<h3 class=fn><a name="~QAccel"></a>QAccel::~QAccel ()
</h3>
Destroys the accelerator object and frees all allocated resources.

<h3 class=fn>void <a name="activated"></a>QAccel::activated ( int&nbsp;id )<tt> [signal]</tt>
</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="clear"></a>QAccel::clear ()
</h3>
Removes all accelerator items.

<h3 class=fn>bool <a name="connectItem"></a>QAccel::connectItem ( int&nbsp;id, const&nbsp;<a href="qobject.html">QObject</a>&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member )
</h3>
Connects the accelerator item <em>id</em> to the slot <em>member</em> of <em>receiver</em>.
<p> <pre>
    a-&gt;connectItem( 201, mainView, SLOT(quit()) );
  </pre>
 
<p> Of course, you can also send a signal as <em>member</em>.
<p> <p>See also <a href="#disconnectItem">disconnectItem</a>().

<p>Example: <a href="t14.html#x2250">t14/gamebrd.cpp</a>.
<h3 class=fn>uint <a name="count"></a>QAccel::count () const
</h3>
Returns the number of accelerator items in this accelerator.

<h3 class=fn>bool <a name="disconnectItem"></a>QAccel::disconnectItem ( int&nbsp;id, const&nbsp;<a href="qobject.html">QObject</a>&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member )
</h3>
Disconnects an accelerator item with id <em>id</em> from the function
called <em>member</em> in the <em>receiver</em> object.
<p> <p>See also <a href="#connectItem">connectItem</a>().

<h3 class=fn>bool <a name="eventFilter"></a>QAccel::eventFilter ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;o, <a href="qevent.html">QEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
</h3>
Processes accelerator events intended for the top level widget.
<em>e</em> is the event that occurred on object <em>o</em>.

<p>Reimplemented from <a href="qobject.html#eventFilter">QObject</a>.
<h3 class=fn>int <a name="findKey"></a>QAccel::findKey ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;key ) const
</h3>
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="insertItem"></a>QAccel::insertItem ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;key, int&nbsp;id = -1 )
</h3>
Inserts an accelerator item and returns the item's identifier.
<p> <em>key</em> is a key code plus a combination of SHIFT, CTRL and ALT.
<em>id</em> is the accelerator item id.
<p> If <em>id</em> is negative, then the item will be assigned a unique
negative identifier less than -1.
<p> <pre>
    QAccel *a = new QAccel( myWindow );        // create accels for myWindow
    a-&gt;<a href="#insertItem">insertItem</a>( CTRL + Key_P, 200 );        // Ctrl+P, e.g. to print document
    a-&gt;<a href="#insertItem">insertItem</a>( ALT + Key_X, 201 );         // Alt+X, e.g. to quit
    a-&gt;<a href="#insertItem">insertItem</a>( UNICODE_ACCEL + 'q', 202 ); // Unicode 'q', e.g. to quit
    a-&gt;<a href="#insertItem">insertItem</a>( <a href="qt.html#Key-enum">Key_D</a> );                    // gets a unique negative id &lt; -1
    a-&gt;<a href="#insertItem">insertItem</a>( CTRL + SHIFT + Key_P );     // gets a unique negative id &lt; -1
  </pre>
 

<p>Example: <a href="t14.html#x2251">t14/gamebrd.cpp</a>.
<h3 class=fn>bool <a name="isEnabled"></a>QAccel::isEnabled () const
</h3>
Returns TRUE if the accelerator is enabled; otherwise returns FALSE.
<p>See also <a href="#setEnabled">setEnabled</a>() and <a href="#isItemEnabled">isItemEnabled</a>().

<h3 class=fn>bool <a name="isItemEnabled"></a>QAccel::isItemEnabled ( int&nbsp;id ) const
</h3>
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="#setItemEnabled">setItemEnabled</a>() and <a href="#isEnabled">isEnabled</a>().

<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="key"></a>QAccel::key ( int&nbsp;id )
</h3>
Returns the key sequence of the accelerator item with identifier <em>id</em>,
or an invalid key sequence (0) if the id cannot be found.

<h3 class=fn><a href="qstring.html">QString</a> <a name="keyToString"></a>QAccel::keyToString ( <a href="qkeysequence.html">QKeySequence</a>&nbsp;k )<tt> [static]</tt>
</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Creates an accelerator string for the key <em>k</em>.
For instance CTRL+Key_O gives "Ctrl+O".  The "Ctrl" etc.
are translated (using <a href="qobject.html#tr">QObject::tr</a>()) in the "QAccel" scope.
<p> The function is superfluous.  Cast the <a href="qkeysequence.html">QKeySequence</a> <em>k</em> to a
<a href="qstring.html">QString</a> for the same effect.

<h3 class=fn>void <a name="removeItem"></a>QAccel::removeItem ( int&nbsp;id )
</h3>
Removes the accelerator item with the identifier <em>id</em>.

<h3 class=fn>void <a name="repairEventFilter"></a>QAccel::repairEventFilter ()
</h3>  Makes sure that the accelerator is watching the correct event filter.
This function is called automatically; you should not need to call it in
application code.

<h3 class=fn>void <a name="setEnabled"></a>QAccel::setEnabled ( bool&nbsp;enable )
</h3>
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 using
<a href="#setItemEnabled">setItemEnabled</a>().  To work, a key must be an enabled item in an
enabled QAccel.
<p> <p>See also <a href="#isEnabled">isEnabled</a>() and <a href="#setItemEnabled">setItemEnabled</a>().

<h3 class=fn>void <a name="setItemEnabled"></a>QAccel::setItemEnabled ( int&nbsp;id, bool&nbsp;enable )
</h3>
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.
<p> To work, an item must be enabled and be in an enabled QAccel.
<p> <p>See also <a href="#isItemEnabled">isItemEnabled</a>() and <a href="#isEnabled">isEnabled</a>().

<h3 class=fn>void <a name="setWhatsThis"></a>QAccel::setWhatsThis ( int&nbsp;id, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text )
</h3>
Sets a What's This help text for the accelerator item <em>id</em> to <em>text</em>.
<p> The text will be shown when the application is in What's This mode
and the user hits the accelerator key.
<p> To set What's This help on a menu item (with or without an
accelerator key), use <a href="qmenudata.html#setWhatsThis">QMenuData::setWhatsThis</a>().
<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>.

<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="shortcutKey"></a>QAccel::shortcutKey ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;str )<tt> [static]</tt>
</h3>
Returns the shortcut key sequence for <em>str</em>, or an invalid key
sequence (0) if <em>str</em> has no shortcut sequence.
<p> For example, <a href="#shortcutKey">shortcutKey</a>("E&amp;xit") returns ALT+Key_X,
shortcutKey("&amp;Exit") returns ALT+Key_E and shortcutKey("Exit")
returns 0.  (In code that does not inherit the Qt namespace class,
you must write e.g. Qt::ALT+Qt::Key_X.)
<p> We provide a <a href="accelerators.html">list of common accelerators</a> in English. At the time of writing, Microsoft and
Open Group do not appear to have issued equivalent recommendations for
other languages.

<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="stringToKey"></a>QAccel::stringToKey ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;s )<tt> [static]</tt>
</h3><b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Returns an accelerator code for the string <em>s</em>.  For example
"Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'.  The strings "Ctrl",
"Shift", "Alt" are recognized, as well as their translated
equivalents in the "QAccel" scope (using <a href="qobject.html#tr">QObject::tr</a>()). Returns 0
if <em>s</em> is not recognized.
<p> This function is typically used with <a href="qobject.html#tr">tr</a>(), so that accelerator keys can be replaced in
translations:
<p> <pre>
    <a href="qpopupmenu.html">QPopupMenu</a> *file = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
    file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( p1, tr("&amp;Open..."), this, SLOT(open()),
                      QAccel::<a href="#stringToKey">stringToKey</a>(<a href="qobject.html#tr">tr</a>("Ctrl+O", "File|Open")) );
  </pre>
 
<p> Notice the <tt>"File|Open"</tt> translator comment. It is by no means
necessary, but it provides some context for the human translator.
<p> The function is superfluous.  Construct a <a href="qkeysequence.html">QKeySequence</a> from the
string <em>s</em> for the same effect.
<p> <p>See also <a href="qobject.html#tr">QObject::tr</a>() and <a href="i18n.html">Internationalization with Qt</a>.

<p>Example: <a href="i18n-example.html#x1356">i18n/mywidget.cpp</a>.
<h3 class=fn><a href="qstring.html">QString</a> <a name="whatsThis"></a>QAccel::whatsThis ( int&nbsp;id ) const
</h3>
Returns the What's This help text for the specified item <em>id</em> or
<a href="qstring.html#QString-null">QString::null</a> if no text has been specified.
<p> <p>See also <a href="#setWhatsThis">setWhatsThis</a>().

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 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 &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>