<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt - 3.3.8 - espenr - 2499/qt - x11 - free - 3.3.8/src/kernel/qaccel.cpp:51 -->
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=ISO-8859-1" >
< title > TQAccel Class< / title >
< style type = "text/css" > < ! - -
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 Classes< / font > < / a >
| < a href = "mainclasses.html" >
< font color = "#004faf" > Main Classes< / font > < / a >
| < a href = "annotated.html" >
< font color = "#004faf" > Annotated< / font > < / a >
| < a href = "groups.html" >
< font color = "#004faf" > Grouped 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 > TQAccel Class Reference< / h1 >
< p > The TQAccel class handles keyboard accelerator and shortcut keys.
< a href = "#details" > More...< / a >
< p > < tt > #include < < a href = "qaccel-h.html" > ntqaccel.h< / a > > < / tt >
< p > Inherits < a href = "tqobject.html" > TQObject< / a > .
< p > < a href = "qaccel-members.html" > List of all member functions.< / a >
< h2 > Public Members< / h2 >
< ul >
< li class = fn > < a href = "#TQAccel" > < b > TQAccel< / b > < / a > ( TQWidget * parent, const char * name = 0 )< / li >
< li class = fn > < a href = "#TQAccel-2" > < b > TQAccel< / b > < / a > ( TQWidget * watch, TQObject * parent, const char * name = 0 )< / li >
< li class = fn > < a href = "#~TQAccel" > < b > ~TQAccel< / b > < / a > ()< / li >
< li class = fn > bool < a href = "#isEnabled" > < b > isEnabled< / b > < / a > () const< / li >
< li class = fn > void < a href = "#setEnabled" > < b > setEnabled< / b > < / a > ( bool enable )< / li >
< li class = fn > uint < a href = "#count" > < b > count< / b > < / a > () const< / li >
< li class = fn > int < a href = "#insertItem" > < b > insertItem< / b > < / a > ( const TQKeySequence & key, int id = -1 )< / li >
< li class = fn > void < a href = "#removeItem" > < b > removeItem< / b > < / a > ( int id )< / li >
< li class = fn > void < a href = "#clear" > < b > clear< / b > < / a > ()< / li >
< li class = fn > TQKeySequence < a href = "#key" > < b > key< / b > < / a > ( int id )< / li >
< li class = fn > int < a href = "#findKey" > < b > findKey< / b > < / a > ( const TQKeySequence & key ) const< / li >
< li class = fn > bool < a href = "#isItemEnabled" > < b > isItemEnabled< / b > < / a > ( int id ) const< / li >
< li class = fn > void < a href = "#setItemEnabled" > < b > setItemEnabled< / b > < / a > ( int id, bool enable )< / li >
< li class = fn > bool < a href = "#connectItem" > < b > connectItem< / b > < / a > ( int id, const TQObject * receiver, const char * member )< / li >
< li class = fn > bool < a href = "#disconnectItem" > < b > disconnectItem< / b > < / a > ( int id, const TQObject * receiver, const char * member )< / li >
< li class = fn > void repairEventFilter () < em > (obsolete)< / em > < / li >
< li class = fn > void < a href = "#setWhatsThis" > < b > setWhatsThis< / b > < / a > ( int id, const TQString & text )< / li >
< li class = fn > TQString < a href = "#whatsThis" > < b > whatsThis< / b > < / a > ( int id ) const< / li >
< / ul >
< h2 > Signals< / h2 >
< ul >
< li class = fn > void < a href = "#activated" > < b > activated< / b > < / a > ( int id )< / li >
< li class = fn > void < a href = "#activatedAmbiguously" > < b > activatedAmbiguously< / b > < / a > ( int id )< / li >
< / ul >
< h2 > Static Public Members< / h2 >
< ul >
< li class = fn > TQKeySequence < a href = "#shortcutKey" > < b > shortcutKey< / b > < / a > ( const TQString & str )< / li >
< li class = fn > TQString keyToString ( TQKeySequence k ) < em > (obsolete)< / em > < / li >
< li class = fn > TQKeySequence stringToKey ( const TQString & s ) < em > (obsolete)< / em > < / li >
< / ul >
< h2 > Protected Members< / h2 >
< ul >
< li class = fn > virtual bool eventFilter ( TQObject *, TQEvent * ) < em > (obsolete)< / em > < / li >
< / ul >
< hr > < a name = "details" > < / a > < h2 > Detailed Description< / h2 >
The TQAccel 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 = "tqaction.html" > TQAction< / 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 = "tqmenudata.html#insertItem" > TQMenuData::insertItem< / a > () or < a href = "tqmenudata.html#setAccel" > TQMenuData::setAccel< / a > () to make
accelerators for operations that are also available on menus. Many
widgets automatically generate accelerators, such as < a href = "ntqbutton.html" > TQButton< / a > ,
< a href = "ntqgroupbox.html" > TQGroupBox< / a > , < a href = "tqlabel.html" > TQLabel< / a > (with < a href = "tqlabel.html#setBuddy" > TQLabel::setBuddy< / a > ()), < a href = "tqmenubar.html" > TQMenuBar< / a > and < a href = "ntqtabbar.html" > TQTabBar< / a > .
Example:
< pre >
< a href = "ntqpushbutton.html" > TQPushButton< / a > p( "& Exit", parent ); // automatic shortcut ALT+Key_E
< a href = "tqpopupmenu.html" > TQPopupMenu< / a > *fileMenu = new fileMenu( parent );
fileMenu-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( "Undo", parent, TQ_SLOT(undo()), CTRL+Key_Z );
< / pre >
< p > A TQAccel 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 = "ntqkeysequence.html" > TQKeySequence< / a > . A single key sequence consists of a keyboard code
combined with modifiers (< a href = "ntqt.html#Modifier-enum" > SHIFT< / a > , < a href = "ntqt.html#Modifier-enum" > CTRL< / a > , < a href = "ntqt.html#Modifier-enum" > ALT< / a > or < a href = "ntqt.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" > ntqnamespace.h< / a > . As an alternative, use < a href = "ntqt.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 = "ntqt.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 > The activated() signal is < em > not< / em > emitted when two or more
accelerators match the same key. Instead, the first matching
accelerator sends out the < a href = "#activatedAmbiguously" > activatedAmbiguously< / a > () signal. By
pressing the key multiple times, users can navigate between all
matching accelerators. Some standard controls like < a href = "ntqpushbutton.html" > TQPushButton< / a > and
< a href = "ntqcheckbox.html" > TQCheckBox< / a > connect the activatedAmbiguously() signal to the
harmless setFocus() slot, whereas activated() is connected to a
slot invoking the button's action. Most controls, like < a href = "tqlabel.html" > TQLabel< / a > and
< a href = "ntqtabbar.html" > TQTabBar< / a > , treat activated() and activatedAmbiguously() as
equivalent.
< p > Use < a href = "#setEnabled" > setEnabled< / a > () to enable or disable all the items in an
accelerator, or < a href = "#setItemEnabled" > setItemEnabled< / a > () to enable or disable individual
items. An item is active only when both the TQAccel 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 > The accelerator will be deleted when < em > parent< / em > is deleted,
and will consume relevant key events until then.
< p > Please note that the accelerator
< pre >
accelerator-> insertItem( TQKeySequence("M") );
< / pre >
can be triggered with both the 'M' key, and with Shift+M,
unless a second accelerator is defined for the Shift+M
combination.
< p > Example:
< pre >
TQAccel *a = new TQAccel( myWindow ); // create accels for myWindow
a-> < a href = "#connectItem" > connectItem< / a > ( a-> < a href = "#insertItem" > insertItem< / a > (Key_P+CTRL), // adds Ctrl+P accelerator
myWindow, // connected to myWindow's
TQ_SLOT(printDoc()) ); // printDoc() slot
< / pre >
< p > < p > See also < a href = "qkeyevent.html" > TQKeyEvent< / a > , < a href = "tqwidget.html#keyPressEvent" > TQWidget::keyPressEvent< / a > (), < a href = "tqmenudata.html#setAccel" > TQMenuData::setAccel< / a > (), < a href = "ntqbutton.html#accel-prop" > TQButton::accel< / a > , < a href = "tqlabel.html#setBuddy" > TQLabel::setBuddy< / a > (), < a href = "ntqkeysequence.html" > TQKeySequence< / 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 = "TQAccel" > < / a > TQAccel::TQAccel ( < a href = "tqwidget.html" > TQWidget< / a > * parent, const char * name = 0 )
< / h3 >
Constructs a TQAccel object called < em > name< / em > , with parent < em > parent< / em > .
The accelerator operates on < em > parent< / em > .
< h3 class = fn > < a name = "TQAccel-2" > < / a > TQAccel::TQAccel ( < a href = "tqwidget.html" > TQWidget< / a > * watch, < a href = "tqobject.html" > TQObject< / a > * parent, const char * name = 0 )
< / h3 >
Constructs a TQAccel object called < em > name< / em > , that operates on < em > watch< / em > , and is a child of < em > parent< / em > .
< p > This constructor is not needed for normal application programming.
< h3 class = fn > < a name = "~TQAccel" > < / a > TQAccel::~TQAccel ()
< / h3 >
Destroys the accelerator object and frees all allocated resources.
< h3 class = fn > void < a name = "activated" > < / a > TQAccel::activated ( int 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.
< p > < p > See also < a href = "#activatedAmbiguously" > activatedAmbiguously< / a > ().
< h3 class = fn > void < a name = "activatedAmbiguously" > < / a > TQAccel::activatedAmbiguously ( int 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.
< p > < p > See also < a href = "#activated" > activated< / a > ().
< h3 class = fn > void < a name = "clear" > < / a > TQAccel::clear ()
< / h3 >
Removes all accelerator items.
< h3 class = fn > bool < a name = "connectItem" > < / a > TQAccel::connectItem ( int id, const < a href = "tqobject.html" > TQObject< / a > * receiver, const char * member )
< / h3 >
Connects the accelerator item < em > id< / em > to the slot < em > member< / em > of < em > receiver< / em > .
< p > < pre >
a-> connectItem( 201, mainView, TQ_SLOT(quit()) );
< / pre >
< p > Of course, you can also send a signal as < em > member< / em > .
< p > Normally accelerators are connected to slots which then receive
the < tt > activated(int id)< / tt > signal with the id of the accelerator
item that was activated. If you choose to connect a specific
accelerator item using this function, the < a href = "#activated" > activated< / a > () signal is
emitted if the associated key sequence is pressed but no < tt > activated(int id)< / tt > signal is emitted.
< p > < p > See also < a href = "#disconnectItem" > disconnectItem< / a > ().
< p > Example: < a href = "tutorial1-14.html#x2437" > t14/gamebrd.cpp< / a > .
< h3 class = fn > uint < a name = "count" > < / a > TQAccel::count () const
< / h3 >
Returns the number of accelerator items in this accelerator.
< h3 class = fn > bool < a name = "disconnectItem" > < / a > TQAccel::disconnectItem ( int id, const < a href = "tqobject.html" > TQObject< / a > * receiver, const char * 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 > TQAccel::eventFilter ( < a href = "tqobject.html" > TQObject< / a > *, < a href = "tqevent.html" > TQEvent< / a > * )< tt > [virtual protected]< / 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.
serves no purpose anymore
< p > Reimplemented from < a href = "tqobject.html#eventFilter" > TQObject< / a > .
< h3 class = fn > int < a name = "findKey" > < / a > TQAccel::findKey ( const < a href = "ntqkeysequence.html" > TQKeySequence< / a > & 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 > TQAccel::insertItem ( const < a href = "ntqkeysequence.html" > TQKeySequence< / a > & key, int id = -1 )
< / h3 >
Inserts an accelerator item and returns the item's identifier.
< p > < em > key< / em > is a key code and an optional 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 >
TQAccel *a = new TQAccel( myWindow ); // create accels for myWindow
a-> < a href = "#insertItem" > insertItem< / a > ( CTRL + Key_P, 200 ); // Ctrl+P, e.g. to print document
a-> < a href = "#insertItem" > insertItem< / a > ( ALT + Key_X, 201 ); // Alt+X, e.g. to quit
a-> < a href = "#insertItem" > insertItem< / a > ( UNICODE_ACCEL + 'q', 202 ); // Unicode 'q', e.g. to quit
a-> < a href = "#insertItem" > insertItem< / a > ( < a href = "ntqt.html#Key-enum" > Key_D< / a > ); // gets a unique negative id < -1
a-> < a href = "#insertItem" > insertItem< / a > ( CTRL + SHIFT + Key_P ); // gets a unique negative id < -1
< / pre >
< p > Example: < a href = "tutorial1-14.html#x2438" > t14/gamebrd.cpp< / a > .
< h3 class = fn > bool < a name = "isEnabled" > < / a > TQAccel::isEnabled () const
< / h3 >
Returns TRUE if the accelerator is enabled; otherwise returns
FALSE.
< p > < p > See also < a href = "#setEnabled" > setEnabled< / a > () and < a href = "#isItemEnabled" > isItemEnabled< / a > ().
< h3 class = fn > bool < a name = "isItemEnabled" > < / a > TQAccel::isItemEnabled ( int 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 > < p > See also < a href = "#setItemEnabled" > setItemEnabled< / a > () and < a href = "#isEnabled" > isEnabled< / a > ().
< h3 class = fn > < a href = "ntqkeysequence.html" > TQKeySequence< / a > < a name = "key" > < / a > TQAccel::key ( int 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 = "tqstring.html" > TQString< / a > < a name = "keyToString" > < / a > TQAccel::keyToString ( < a href = "ntqkeysequence.html" > TQKeySequence< / a > 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 = "tqobject.html#tr" > TQObject::tr< / a > ()) in the "TQAccel" context.
< p > The function is superfluous. Cast the < a href = "ntqkeysequence.html" > TQKeySequence< / a > < em > k< / em > to a
< a href = "tqstring.html" > TQString< / a > for the same effect.
< h3 class = fn > void < a name = "removeItem" > < / a > TQAccel::removeItem ( int id )
< / h3 >
Removes the accelerator item with the identifier < em > id< / em > .
< h3 class = fn > void < a name = "repairEventFilter" > < / a > TQAccel::repairEventFilter ()
< / h3 > < b > This function is obsolete.< / b > It is provided to keep old source working. We strongly advise against using it in new code.
serves no purpose anymore
< h3 class = fn > void < a name = "setEnabled" > < / a > TQAccel::setEnabled ( bool 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 TQAccel.
< p > < p > See also < a href = "#isEnabled" > isEnabled< / a > () and < a href = "#setItemEnabled" > setItemEnabled< / a > ().
< h3 class = fn > void < a name = "setItemEnabled" > < / a > TQAccel::setItemEnabled ( int id, bool 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 TQAccel.
< p > < p > See also < a href = "#isItemEnabled" > isItemEnabled< / a > () and < a href = "#isEnabled" > isEnabled< / a > ().
< h3 class = fn > void < a name = "setWhatsThis" > < / a > TQAccel::setWhatsThis ( int id, const < a href = "tqstring.html" > TQString< / a > & 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 = "tqmenudata.html#setWhatsThis" > TQMenuData::setWhatsThis< / a > ().
< p > < p > See also < a href = "#whatsThis" > whatsThis< / a > (), < a href = "tqwhatsthis.html#inWhatsThisMode" > TQWhatsThis::inWhatsThisMode< / a > (), < a href = "tqmenudata.html#setWhatsThis" > TQMenuData::setWhatsThis< / a > (), and < a href = "tqaction.html#whatsThis-prop" > TQAction::whatsThis< / a > .
< h3 class = fn > < a href = "ntqkeysequence.html" > TQKeySequence< / a > < a name = "shortcutKey" > < / a > TQAccel::shortcutKey ( const < a href = "tqstring.html" > TQString< / a > & 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& xit") returns ALT+Key_X,
shortcutKey("& Quit") returns ALT+Key_Q and shortcutKey("Quit")
returns 0. (In code that does not inherit the TQt namespace class,
you must write e.g. TQt::ALT+TQt::Key_Q.)
< 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 = "ntqkeysequence.html" > TQKeySequence< / a > < a name = "stringToKey" > < / a > TQAccel::stringToKey ( const < a href = "tqstring.html" > TQString< / a > & 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 "TQAccel" context (using < a href = "tqobject.html#tr" > TQObject::tr< / a > ()). Returns 0
if < em > s< / em > is not recognized.
< p > This function is typically used with < a href = "tqobject.html#tr" > tr< / a > (), so that accelerator keys can be replaced in
translations:
< p > < pre >
< a href = "tqpopupmenu.html" > TQPopupMenu< / a > *file = new < a href = "tqpopupmenu.html" > TQPopupMenu< / a > ( this );
file-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( p1, tr("& Open..."), this, TQ_SLOT(open()),
TQAccel::< a href = "#stringToKey" > stringToKey< / a > (< a href = "tqobject.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 = "ntqkeysequence.html" > TQKeySequence< / a > from the
string < em > s< / em > for the same effect.
< p > < p > See also < a href = "tqobject.html#tr" > TQObject::tr< / a > () and < a href = "i18n.html" > Internationalization with TQt< / a > .
< p > Example: < a href = "i18n-example.html#x1921" > i18n/mywidget.cpp< / a > .
< h3 class = fn > < a href = "tqstring.html" > TQString< / a > < a name = "whatsThis" > < / a > TQAccel::whatsThis ( int id ) const
< / h3 >
Returns the What's This help text for the specified item < em > id< / em > or
< a href = "tqstring.html#TQString-null" > TQString::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" > TQt toolkit< / a > .
Copyright © 1995-2007
< 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 © 2007
< a href = "troll.html" > Trolltech< / a > < td align = center > < a href = "trademarks.html" > Trademarks< / a >
< td align = right > < div align = right > TQt 3.3.8< / div >
< / table > < / div > < / address > < / body >
< / html >