![]() |
Home · All Classes · Main Classes · Grouped Classes · Modules · Functions | ![]() |
The QKeySequence class encapsulates a key sequence as used by shortcuts. More...
#include <QKeySequence>
The QKeySequence class encapsulates a key sequence as used by shortcuts.
A key sequence consists of up to four keyboard codes, each optionally combined with modifiers, such as Qt::SHIFT, Qt::CTRL, Qt::ALT or Qt::META. For example, Qt::CTRL + Qt::Key_P might be a sequence used as a shortcut for printing a document. Valid codes for keys and modifiers are listed in Qt::Key and Qt::Modifier. As an alternative, use the unicode code point of the character; for example, 'A' gives the same key sequence as Qt::Key_A.
Key sequences can be constructed either from an integer key code, or from a human readable translatable string such as "Ctrl+X,Alt+Space". A key sequence can be cast to a QString to obtain a human readable translated version of the sequence. Translations are done in the "QShortcut" context.
Note: On Mac OS X, references to "Ctrl", Qt::CTRL, Qt::Control and Qt::ControlModifier correspond to the Command keys on the Macintosh keyboard, and references to "Meta", Qt::META, Qt::Meta and Qt::MetaModifier correspond to the Control keys. Developers on Mac OS X can use the same shortcut descriptions across all platforms, and their applications will automatically work as expected on Mac OS X.
The toString() function produces human-readable strings for use in menus. On Mac OS X, the appropriate symbols are used to describe keyboard shortcuts using special keys on the Macintosh keyboard.
See also QShortcut.
Constant | Value | Description |
---|---|---|
QKeySequence::NativeText | 0 | The key sequence as a platform specific string. This means that it will be shown translated and on the Mac it will resemble a keysequence from the menu bar. This enum is best used when you want to display the string to the user. |
QKeySequence::PortableText | 1 | The key sequence is given in a "portable" format, suitable for reading and writing to a file. In many cases, it will look similar to the native text on Windows and X11. |
Constant | Value | Description |
---|---|---|
QKeySequence::NoMatch | 0 | The key sequences are different; not even partially matching. |
QKeySequence::PartialMatch | 1 | The key sequences match partially, but are not the same. |
QKeySequence::ExactMatch | 2 | The key sequences are the same. |
This enum represent standard key bindings. They can be used to assign platform dependent keyboard shortcuts to a QAction. QKeyEvent also provides the function QKeyEvent::standardKey() to query if it matches an existing keyBinding.
Note that the key bindings are platform dependent. The currently bound shortcuts can be queried through keyBindings.
Constant | Value | Description |
---|---|---|
QKeySequence::UnknownKey | 0 | Unbound key |
QKeySequence::HelpContents | 1 | Open help contents. Usually "F1". |
QKeySequence::WhatsThis | 2 | Activate whats this. Usually "Shift + F1". |
QKeySequence::Open | 3 | Open Document. Usually "Ctrl + O". |
QKeySequence::Close | 4 | Close Document/Tab. Usually "Ctrl + W". |
QKeySequence::Save | 5 | Save Document. Usually "Ctrl + S". |
QKeySequence::New | 6 | Create new Document. Usually "Ctrl + N". |
QKeySequence::Delete | 7 | Delete |
QKeySequence::Cut | 8 | Cut. Usually "Ctrl + X". |
QKeySequence::Copy | 9 | Copy. Usually "Ctrl + C". |
QKeySequence::Paste | 10 | Paste. Usually "Ctrl + V". |
QKeySequence::Undo | 11 | Undo. Usually "Ctrl + Z". |
QKeySequence::Redo | 12 | Redo. Usually "Ctrl + Shift + Z". |
QKeySequence::Back | 13 | Navigate back. Usually "Alt + Left". |
QKeySequence::Forward | 14 | Navigate forward. Usually "Alt + Right". |
QKeySequence::Refresh | 15 | Refresh or reload current document. This is usually F5. |
QKeySequence::ZoomIn | 16 | Zoom in. Usually "Ctrl + Plus". |
QKeySequence::ZoomOut | 17 | Zoom out. Usually "Ctrl + Minus". |
QKeySequence::Print | 18 | Print document. Usually "Ctrl + P". |
QKeySequence::AddTab | 19 | Add new tab. Usually "Ctrl + T". |
QKeySequence::NextChild | 20 | Navigate to next tab or child window. Usually "Ctrl + Tab". |
QKeySequence::PreviousChild | 21 | Navigate to previous tab or child window. Usually "Ctrl + Shift + Tab". |
QKeySequence::Find | 22 | Find in document. Usually "Ctrl + F". |
QKeySequence::FindNext | 23 | Find next result. Usually "Ctrl + G". |
QKeySequence::FindPrevious | 24 | Find previous result. Usually "Ctrl + Shift + G". |
QKeySequence::Replace | 25 | Find and replace. Usually "Ctrl + H". |
QKeySequence::SelectAll | 26 | Select all text. Usually "Ctrl + A". |
QKeySequence::Bold | 27 | Bold text. Usually "Ctrl + B". |
QKeySequence::Italic | 28 | Italic text. Usually "Ctrl + I". |
QKeySequence::Underline | 29 | Underline text. Usually "Ctrl + U". |
QKeySequence::Return | This usually indicates either the enter or return key. | |
QKeySequence::Backspace | This usually indicates the backspace key. | |
QKeySequence::MoveToNextChar | 30 | Move to next character. Usually right arrow key. |
QKeySequence::MoveToPreviousChar | 31 | Move to previous character. Usually right arrow key. |
QKeySequence::MoveToNextWord | 32 | Move to next word. Usually "Ctrl + Right". |
QKeySequence::MoveToPreviousWord | 33 | Move to previous word. Usually "Ctrl + Right". |
QKeySequence::MoveToNextLine | 34 | Move to next line. Usually the down arrow key. |
QKeySequence::MoveToPreviousLine | 35 | Move to previous line. Usually up arrow key. |
QKeySequence::MoveToNextPage | 36 | Move to next page. Usually the page down key. |
QKeySequence::MoveToPreviousPage | 37 | Move to previous page. Usually the page up key. |
QKeySequence::MoveToStartOfLine | 38 | Move to start of line. Usually the home key. |
QKeySequence::MoveToEndOfLine | 39 | Move to end of line. Usually the end key. |
QKeySequence::MoveToStartOfBlock | 40 | Move to start of a block. This corresponds to "command + up" on Mac. |
QKeySequence::MoveToEndOfBlock | 41 | Move to end of block. This corresponds to "command + down" on Mac. |
QKeySequence::MoveToStartOfDocument | 42 | Move to start of document. Usually "Ctrl + Home". |
QKeySequence::MoveToEndOfDocument | 43 | Move to end of document. Usually "Ctrl + End". |
QKeySequence::SelectNextChar | 44 | Extend selection to next character. Usually "Shift + Right". |
QKeySequence::SelectPreviousChar | 45 | Extend selection to previous character. Usually "Shift + Left". |
QKeySequence::SelectNextWord | 46 | Extend selection to next word. Usually "Ctrl + Shift + Right". |
QKeySequence::SelectPreviousWord | 47 | Extend selection to previous word. Usually "Ctrl + Shift + Right". |
QKeySequence::SelectNextLine | 48 | Extend selection to next line. Usually "Shift + Down". |
QKeySequence::SelectPreviousLine | 49 | Extend selection to previous line. Usually "Shift + Up". |
QKeySequence::SelectNextPage | 50 | Extend selection to next page. Usually "Shift + PageDown". |
QKeySequence::SelectPreviousPage | 51 | Extend selection to previous page. Usually "Shift + PageUp". |
QKeySequence::SelectStartOfLine | 52 | Extend selection to start of line. Usually "Shift + Home". |
QKeySequence::SelectEndOfLine | 53 | Extend selection to end of line. Usually "Shift + End". |
QKeySequence::SelectStartOfBlock | 54 | Extend selection to the start of a text block. This corresponds to "command + shift + up" on Mac. |
QKeySequence::SelectEndOfBlock | 55 | Extend selection to the end of a text block. This corresponds to "command + shift + down" on Mac. |
QKeySequence::SelectStartOfDocument | 56 | Extend selection to start of document. This is usually "Ctrl + Shift + Home". |
QKeySequence::SelectEndOfDocument | 57 | Extend selection to end of document. This is usually "Ctrl + Shift + End". |
QKeySequence::DeleteStartOfWord | 58 | Delete the beginning of a word up to the cursor. This is usually "Ctrl + Backspace". |
QKeySequence::DeleteEndOfWord | 59 | Delete word from the end of the cursor. This is usually "Ctrl + Delete". |
QKeySequence::DeleteEndOfLine | 60 | Delete end of line. Usually "Ctrl + K". |
See also drawPrimitive().
Constructs an empty key sequence.
Creates a key sequence from the key string. For example "Ctrl+O" gives CTRL+'O'. The strings "Ctrl", "Shift", "Alt" and "Meta" are recognized, as well as their translated equivalents in the "QShortcut" context (using QObject::tr()).
Up to four key codes may be entered by separating them with commas, e.g. "Alt+X,Ctrl+S,Q".
This contructor is typically used with tr(), so that shortcut keys can be replaced in translations:
QMenu *file = new QMenu(this); file->addAction(tr("&Open..."), this, SLOT(open()), QKeySequence(tr("Ctrl+O", "File|Open")));
Note the "File|Open" translator comment. It is by no means necessary, but it provides some context for the human translator.
Constructs a key sequence with up to 4 keys k1, k2, k3 and k4.
The key codes are listed in Qt::Key and can be combined with modifiers (see Qt::Modifier) such as Qt::SHIFT, Qt::CTRL, Qt::ALT, or Qt::META.
Copy constructor. Makes a copy of keysequence.
Destroys the key sequence.
Returns the number of keys in the key sequence. The maximum is 4.
Return a QKeySequence from the string str based on format.
This function was introduced in Qt 4.1.
See also toString().
Returns true if the key sequence is empty; otherwise returns false.
Matches the sequence with seq. Returns ExactMatch if successful, PartialMatch if seq matches incompletely, and NoMatch if the sequences have nothing in common. Returns NoMatch if seq is shorter.
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics are found.
For example, mnemonic("E&xit") returns Qt::ALT+Qt::Key_X, mnemonic("&Quit") returns ALT+Key_Q, and mnemonic("Quit") returns an empty QKeySequence.
We provide a list of common mnemonics in English. At the time of writing, Microsoft and Open Group do not appear to have issued equivalent recommendations for other languages.
Return a string representation of the key sequence based on format.
This function was introduced in Qt 4.1.
See also fromString().
Creates a shortcut string for the key sequence.
For example, the value Qt::CTRL+Qt::Key_O results in "Ctrl+O". If the key sequence has multiple key codes, each is separated by commas in the string returned, such as "Alt+X, Ctrl+Y, Z". The strings, "Ctrl", "Shift", etc. are translated using QObject::tr() in the "QShortcut" scope.
If the key sequence has no keys, an empty string is returned.
On Mac OS X, the string returned resembles the sequence that is shown in the menubar.
See also toString().
Returns the key sequence as a QVariant
Returns true if this key sequence is not equal to the other key sequence; otherwise returns false.
Provides an arbitrary comparison of this key sequence and other key sequence. All that is guaranteed is that the operator returns false if both key sequences are equal and that (ks1 < ks2) == !( ks2 < ks1) if the key sequences are not equal.
This function is useful in some circumstances, for example if you want to use QKeySequence objects as keys in a QMap.
See also operator==(), operator!=(), operator>(), operator<=(), and operator>=().
Returns true if this key sequence is smaller or equal to the other key sequence; otherwise returns false.
See also operator==(), operator!=(), operator<(), operator>(), and operator>=().
Assignment operator. Assigns the other key sequence to this object.
Returns true if this key sequence is equal to the other key sequence; otherwise returns false.
Returns true if this key sequence is larger than the other key sequence; otherwise returns false.
See also operator==(), operator!=(), operator<(), operator<=(), and operator>=().
Returns true if this key sequence is larger or equal to the other key sequence; otherwise returns false.
See also operator==(), operator!=(), operator<(), operator>(), and operator<=().
Returns a reference to the element at position index in the key sequence. This can only be used to read an element.
This is an overloaded member function, provided for convenience.
Writes the key sequence to the stream.
See also Format of the QDataStream operators.
This is an overloaded member function, provided for convenience.
Reads a key sequence from the stream into the key sequence.
See also Format of the QDataStream operators.
Copyright © 2006 Trolltech | Trademarks | Qt 4.2.0-tp1 |