📄 qaccel.3qt
字号:
.TH QAccel 3qt "9 July 1999" "Troll Tech AS" \" -*- nroff -*-.\" Copyright 1992-1999 Troll Tech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQAccel \- Handles keyboard accelerator and shortcut keys.SH SYNOPSIS.br.PP\fC#include <qaccel.h>\fR.PPInherits QObject..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQAccel\fR ( QWidget * " "parent" ", const char * " "name" "=0 )".br.ti -1c.BI "\fB~QAccel\fR ()".br.ti -1c.BI "bool \fBisEnabled\fR () const".br.ti -1c.BI "void \fBsetEnabled\fR ( bool )".br.ti -1c.BI "uint \fBcount\fR () const".br.ti -1c.BI "int \fBinsertItem\fR ( int " "key" ", int " "id" "=-1 )".br.ti -1c.BI "void \fBremoveItem\fR ( int id )".br.ti -1c.BI "void \fBclear\fR ()".br.ti -1c.BI "int \fBkey\fR ( int id )".br.ti -1c.BI "int \fBfindKey\fR ( int key ) const".br.ti -1c.BI "bool \fBisItemEnabled\fR ( int id ) const".br.ti -1c.BI "void \fBsetItemEnabled\fR ( int " "id" ", bool enable )".br.ti -1c.BI "bool \fBconnectItem\fR ( int " "id" ", const QObject * " "receiver" ", const char * member )".br.ti -1c.BI "bool \fBdisconnectItem\fR ( int " "id" ", const QObject * " "receiver" ", const char * member )".br.ti -1c.BI "void \fBrepairEventFilter\fR ()".br.ti -1c.BI "void \fBsetWhatsThis\fR ( int " "id" ", const QString & )".br.ti -1c.BI "QString \fBwhatsThis\fR ( int id ) const".br.ti -1c.BI "void \fBsetIgnoreWhatsThis\fR ( bool )".br.ti -1c.BI "bool \fBignoreWhatsThis\fR () const".br.in -1c.SS "Signals".in +1c.ti -1c.BI "void \fBactivated\fR ( int id )".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "int \fBshortcutKey\fR ( const QString & )".br.ti -1c.BI "QString \fBkeyToString\fR ( int k )".br.ti -1c.BI "int \fBstringToKey\fR ( const QString & )".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual bool \fBeventFilter\fR ( QObject *, QEvent * )".br.in -1c.SH DESCRIPTIONThe QAccel class handles keyboard accelerator and shortcut keys..PPA QAccel contains a list of accelerator items. Each accelerator item consists of an identifier and a keyboard code combined with modifiers (\fCSHIFT, CTRL, ALT\fR or \fCUNICODE_ACCEL).\fR.PPFor example, \fCCTRL + Key_P\fR could be a shortcut for printing a document. The key codes are listed in qnamespace.h..PPWhen pressed, an accelerator key sends out the signal activated() 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 connectItem())..PPA QAccel object handles key events to the top level window containing \fIparent,\fR and hence to any child widgets of that window. Note that the accelerator will be deleted only when the \fIparent\fR is deleted, and will consume relevant key events until then..PPExample:.PP.nf.br QAccel *a = new QAccel( myWindow ); // create accels for myWindow.br a->connectItem( a->insertItem(Key_P+CTRL), // adds Ctrl+P accelerator.br myWindow, // connected to myWindow's.br SLOT(printDoc()) ); // printDoc() slot.fi.PPSee also: QKeyEvent, QWidget::keyPressEvent(), QMenuData::setAccel(), QButton::setAccel() and GUI Design Handbook: Keyboard Shortcuts,.SH MEMBER FUNCTION DOCUMENTATION.SH "QAccel::QAccel ( QWidget * parent, const char * name=0 )"Creates a QAccel object with a parent widget and a name..SH "QAccel::~QAccel ()"Destroys the accelerator object..SH "void QAccel::activated ( int id ) \fC[signal]\fR"This signal is emitted when an accelerator key is pressed. \fIid\fR is a number that identifies this particular accelerator item..SH "void QAccel::clear ()"Removes all accelerator items..SH "bool QAccel::connectItem ( int id, const QObject * receiver, const char * member )"Connects an accelerator item to a slot/signal in another object..PPArguments:.TP\fIid\fR is the accelerator item id..TP\fIreceiver\fR is the object to receive a signal..TP\fImember\fR is a slot or signal function in the receiver..PP.nf.br a->connectItem( 201, mainView, SLOT(quit()) );.fi.PPSee also: disconnectItem()..SH "uint QAccel::count () const"Returns the number of accelerator items..SH "bool QAccel::disconnectItem ( int id, const QObject * receiver, const char * member )"Disconnects an accelerator item from a function in another object..PPSee also: connectItem()..SH "bool QAccel::eventFilter ( QObject *, QEvent * e ) \fC[virtual protected]\fR"Processes accelerator events intended for the top level widget..PPReimplemented from QObject..SH "int QAccel::findKey ( int key ) const"Returns the identifier of the accelerator item with the key code \fIkey,\fR or -1 if the item cannot be found..SH "int QAccel::insertItem ( int key, int id=-1 )"Inserts an accelerator item and returns the item's identifier..PPArguments:.TP\fIkey\fR is a key code plus a combination of SHIFT, CTRL and ALT..TP\fIid\fR is the accelerator item id. If \fIid\fR is negative, then the item will be assigned a unique identifier..PP.nf.br QAccel *a = new QAccel( myWindow ); // create accels for myWindow.br a->insertItem( Key_P + CTRL, 200 ); // Ctrl+P to print document.br a->insertItem( Key_X + ALT , 201 ); // Alt+X to quit.br a->insertItem( UNICODE_ACCEL + 'q', 202 ); // Unicode 'q' to quit.br a->insertItem( Key_D ); // gets id 3.br a->insertItem( Key_P + CTRL + SHIFT ); // gets id 4.fi.SH "bool QAccel::isEnabled () const"Returns TRUE if the accelerator is enabled, or FALSE if it is disabled..PPSee also: setEnabled() and isItemEnabled()..SH "bool QAccel::isItemEnabled ( int id ) const"Returns TRUE if the accelerator item with the identifier \fIid\fR is enabled. Returns FALSE if the item is disabled or cannot be found..PPSee also: setItemEnabled() and isEnabled()..SH "int QAccel::key ( int id )"Returns the key code of the accelerator item with the identifier \fIid,\fR or zero if the id cannot be found..SH "QString QAccel::keyToString ( int k ) \fC[static]\fR"Creates an accelerator string for the key \fIk.\fR For instance CTRL+Key_O gives "Ctrl+O". The "Ctrl" etc. are translated in the "QAccel" scope..PPSee also: stringToKey()..SH "void QAccel::removeItem ( int id )"Removes the accelerator item with the identifier \fIid.\fR.SH "void QAccel::repairEventFilter ()"Make sure that the accelerator is watching the correct event filter. Used by QWidget::reparent()..SH "void QAccel::setEnabled ( bool enable )"Enables the accelerator if \fIenable\fR is TRUE, or disables it if \fIenable\fR is FALSE..PPIndividual keys can also be enabled or disabled..PPSee also: isEnabled() and setItemEnabled()..SH "void QAccel::setItemEnabled ( int id, bool enable )"Enables or disables an accelerator item..PPArguments:.TP\fIid\fR is the item identifier..TP\fIenable\fR specifies whether the item should be enabled or disabled..PPSee also: isItemEnabled() and isEnabled()..SH "void QAccel::setWhatsThis ( int id, const QString & text )"Sets a Whats This help for a certain accelerator..PPArguments:.TP\fIid\fR is the accelerator item id..TP\fItext\fR is the Whats This help text. The text will be shown when the application is in What's This mode and the user either hits the respective accelerator key or selects a menu item that has been attached to this accelerator..PPSee also: whatsThis() and QWhatsThis::inWhatsThisMode()..SH "int QAccel::shortcutKey ( const QString & str ) \fC[static]\fR"Returns the shortcut key for \fIstring,\fR or 0 if \fIstring\fR has no shortcut sequence..PPFor example, acceleratorKey("E&xit") returns ALT+Key_X, shortcutChar("&Exit") returns ALT+Key_E and shortcutChar("Exit") returns 0. (In code that does not inherit the Qt namespace class, you need to write e.g. Qt::ALT+Qt::Key_X.).PPWe provide a list of common accelerators in English. (At the time of writing the Microsoft and The Open Group appear to not have issued such recommendations for other languages.)..SH "int QAccel::stringToKey ( const QString & s ) \fC[static]\fR"Creates an accelerator code for the string \fIs.\fR For example "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl", "Shift", "Alt" and their translated equivalents in the "QAccel" scope are recognized..PPA common usage of this function is to provide translatable accelerator values for menus:.PP.nf.br QPopupMenu* file = new QPopupMenu(this);.br file->insertItem( p1, tr("&Open..."), this, SLOT(open()),.br QAccel::stringToKey(tr("Ctrl+O")) );.fi.PPNote that this function currently only supports character accelerators (unlike keyToString() which can produce Ctrl+Backspace, etc. from the appropriate key codes)..SH "QString QAccel::whatsThis ( int id ) const"Returns the Whats This help text for the specified item \fIid\fR or QString::null if no text has been defined yet..PPSee also: setWhatsThis()..SH "SEE ALSO".BR http://www.troll.no/qt/qaccel.html.SH COPYRIGHTCopyright 1992-1999 Troll Tech AS. See the license file included inthe distribution for a complete license statement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -