QKeySequence 类

The QKeySequence class encapsulates a key sequence as used by shortcuts. 更多...

头: #include <QKeySequence>
qmake: QT += gui

公共类型

enum SequenceFormat { NativeText, PortableText }
enum SequenceMatch { NoMatch, PartialMatch, ExactMatch }
enum StandardKey { AddTab, Back, Backspace, Bold, ..., Cancel }

公共函数

QKeySequence ()
QKeySequence (const QString & key , SequenceFormat format = NativeText)
QKeySequence (int k1 , int k2 = 0, int k3 = 0, int k4 = 0)
QKeySequence (const QKeySequence & keysequence )
QKeySequence (StandardKey key )
~QKeySequence ()
int count () const
bool isEmpty () const
SequenceMatch matches (const QKeySequence & seq ) const
void swap (QKeySequence & other )
QString toString (SequenceFormat format = PortableText) const
operator QVariant () const
bool operator!= (const QKeySequence & other ) const
bool operator< (const QKeySequence & other ) const
bool operator<= (const QKeySequence & other ) const
QKeySequence & operator= (const QKeySequence & other )
QKeySequence & operator= (QKeySequence && other )
bool operator== (const QKeySequence & other ) const
bool operator> (const QKeySequence & other ) const
bool operator>= (const QKeySequence & other ) const
int operator[] (uint index ) const

静态公共成员

QKeySequence fromString (const QString & str , SequenceFormat format = PortableText)
QList<QKeySequence> keyBindings (StandardKey key )
QList<QKeySequence> listFromString (const QString & str , SequenceFormat format = PortableText)
QString listToString (const QList<QKeySequence> & list , SequenceFormat format = PortableText)
QKeySequence mnemonic (const QString & text )
void qt_set_sequence_auto_mnemonic (bool b )
QDataStream & operator<< (QDataStream & stream , const QKeySequence & sequence )
QDataStream & operator>> (QDataStream & stream , QKeySequence & sequence )

详细描述

The QKeySequence class encapsulates a key sequence as used by shortcuts.

在最常见形式中,键序列描述必须一起使用以履行某些动作的键组合。键序列用于 QAction 对象以指定可以使用哪些键盘快捷方式来触发动作。

为用作键盘快捷方式,可以按 3 种不同方式构造键序列:

  • 对于标准快捷方式, 标准键 可以用于请求关联各快捷方式的特定平台键序列。
  • 对于自定义快捷方式,可以使用人类可读字符串 (譬如 Ctrl+X),且可以将这些翻译成用于不同语言用户的合适快捷方式。翻译的进行是在 QShortcut 上下文。
  • 对于硬编码快捷方式,可以采用值的组合指定整数键代码定义通过 Qt::Key and Qt::Modifier 枚举值。各键码的组成由单个 Qt::Key 值和 0 个或更多修饰符,譬如 Qt::SHIFT , Qt::CTRL , Qt::ALT and Qt::META .

例如, Ctrl P 可能是用作打印文档的快捷方式序列,且可以按以下任一方式指定:

QKeySequence(QKeySequence::Print);
QKeySequence(tr("Ctrl+P"));
QKeySequence(tr("Ctrl+p"));
QKeySequence(Qt::CTRL + Qt::Key_P);
					

Note that, for letters, the case used in the specification string does not matter. In the above examples, the user does not need to hold down the Shift key to activate a shortcut specified with "Ctrl+P". However, for other keys, the use of Shift as an unspecified extra modifier key can lead to confusion for users of an application whose keyboards have different layouts to those used by the developers. See the 键盘布局问题 section below for more details.

It is preferable to use standard shortcuts where possible. When creating key sequences for non-standard shortcuts, you should use human-readable strings in preference to hard-coded integer values.

QKeySequence objects can be cast to a QString to obtain a human-readable translated version of the sequence. Similarly, the toString () function produces human-readable strings for use in menus. On macOS, the appropriate symbols are used to describe keyboard shortcuts using special keys on the Macintosh keyboard.

An alternative way to specify hard-coded key codes is to use the Unicode code point of the character; for example, 'A' gives the same key sequence as Qt::Key_A .

注意: On macOS, references to "Ctrl", Qt::CTRL , Qt::Key_Control and Qt::ControlModifier correspond to the Command keys on the Macintosh keyboard, and references to "Meta", Qt::META , Qt::Key_Meta and Qt::MetaModifier correspond to the Control keys. Developers on macOS can use the same shortcut descriptions across all platforms, and their applications will automatically work as expected on macOS.

标准快捷键

QKeySequence defines many 标准键盘快捷键 to reduce the amount of effort required when setting up actions in a typical application. The table below shows some common key sequences that are often used for these standard shortcuts by applications on four widely-used platforms. Note that on macOS, the Ctrl value corresponds to the Command keys on the Macintosh keyboard, and the Meta value corresponds to the Control keys.

StandardKey Windows macOS KDE GNOME
HelpContents F1 Ctrl+? F1 F1
WhatsThis Shift+F1 Shift+F1 Shift+F1 Shift+F1
Open Ctrl+O Ctrl+O Ctrl+O Ctrl+O
Close Ctrl+F4, Ctrl+W Ctrl+W, Ctrl+F4 Ctrl+W Ctrl+W
Save Ctrl+S Ctrl+S Ctrl+S Ctrl+S
Quit Ctrl+Q Ctrl+Q Ctrl+Q
SaveAs Ctrl+Shift+S Ctrl+Shift+S
New Ctrl+N Ctrl+N Ctrl+N Ctrl+N
删除 Del Del, Meta+D Del, Ctrl+D Del, Ctrl+D
Cut Ctrl+X, Shift+Del Ctrl+X, Meta+K Ctrl+X, F20, Shift+Del Ctrl+X, F20, Shift+Del
Copy Ctrl+C, Ctrl+Ins Ctrl+C Ctrl+C, F16, Ctrl+Ins Ctrl+C, F16, Ctrl+Ins
Paste Ctrl+V, Shift+Ins Ctrl+V, Meta+Y Ctrl+V, F18, Shift+Ins Ctrl+V, F18, Shift+Ins
首选项 Ctrl+,
Undo Ctrl+Z, Alt+Backspace Ctrl+Z Ctrl+Z, F14 Ctrl+Z, F14
Redo Ctrl+Y, Shift+Ctrl+Z, Alt+Shift+Backspace Ctrl+Shift+Z Ctrl+Shift+Z Ctrl+Shift+Z
Back Alt+Left, Backspace Ctrl+[ Alt+Left Alt+Left
Forward Alt+Right, Shift+Backspace Ctrl+] Alt+Right Alt+Right
Refresh F5 F5 F5 Ctrl+R, F5
ZoomIn Ctrl+Plus Ctrl+Plus Ctrl+Plus Ctrl+Plus
ZoomOut Ctrl+Minus Ctrl+Minus Ctrl+Minus Ctrl+Minus
FullScreen F11, Alt+Enter Ctrl+Meta+F F11, Ctrl+Shift+F Ctrl+F11
打印 Ctrl+P Ctrl+P Ctrl+P Ctrl+P
AddTab Ctrl+T Ctrl+T Ctrl+Shift+N, Ctrl+T Ctrl+T
NextChild Ctrl+Tab, Forward, Ctrl+F6 Ctrl+}, Forward, Ctrl+Tab Ctrl+Tab, Forward, Ctrl+Comma Ctrl+Tab, Forward
PreviousChild Ctrl+Shift+Tab, Back, Ctrl+Shift+F6 Ctrl+{, Back, Ctrl+Shift+Tab Ctrl+Shift+Tab, Back, Ctrl+Period Ctrl+Shift+Tab, Back
Find Ctrl+F Ctrl+F Ctrl+F Ctrl+F
FindNext F3, Ctrl+G Ctrl+G F3 Ctrl+G, F3
FindPrevious Shift+F3, Ctrl+Shift+G Ctrl+Shift+G Shift+F3 Ctrl+Shift+G, Shift+F3
替换 Ctrl+H (none) Ctrl+R Ctrl+H
SelectAll Ctrl+A Ctrl+A Ctrl+A Ctrl+A
Deselect Ctrl+Shift+A Ctrl+Shift+A
Bold Ctrl+B Ctrl+B Ctrl+B Ctrl+B
Italic Ctrl+I Ctrl+I Ctrl+I Ctrl+I
Underline Ctrl+U Ctrl+U Ctrl+U Ctrl+U
MoveToNextChar Right Right, Meta+F Right Right
MoveToPreviousChar Left Left, Meta+B Left Left
MoveToNextWord Ctrl+Right Alt+Right Ctrl+Right Ctrl+Right
MoveToPreviousWord Ctrl+Left Alt+Left Ctrl+Left Ctrl+Left
MoveToNextLine Down Down, Meta+N Down Down
MoveToPreviousLine Up Up, Meta+P Up Up
MoveToNextPage PgDown PgDown, Alt+PgDown, Meta+Down, Meta+PgDown, Meta+V PgDown PgDown
MoveToPreviousPage PgUp PgUp, Alt+PgUp, Meta+Up, Meta+PgUp PgUp PgUp
MoveToStartOfLine Home Ctrl+Left, Meta+Left Home Home
MoveToEndOfLine End Ctrl+Right, Meta+Right End, Ctrl+E End, Ctrl+E
MoveToStartOfBlock (none) Alt+Up, Meta+A (none) (none)
MoveToEndOfBlock (none) Alt+Down, Meta+E (none) (none)
MoveToStartOfDocument Ctrl+Home Ctrl+Up, Home Ctrl+Home Ctrl+Home
MoveToEndOfDocument Ctrl+End Ctrl+Down, End Ctrl+End Ctrl+End
SelectNextChar Shift+Right Shift+Right Shift+Right Shift+Right
SelectPreviousChar Shift+Left Shift+Left Shift+Left Shift+Left
SelectNextWord Ctrl+Shift+Right Alt+Shift+Right Ctrl+Shift+Right Ctrl+Shift+Right
SelectPreviousWord Ctrl+Shift+Left Alt+Shift+Left Ctrl+Shift+Left Ctrl+Shift+Left
SelectNextLine Shift+Down Shift+Down Shift+Down Shift+Down
SelectPreviousLine Shift+Up Shift+Up Shift+Up Shift+Up
SelectNextPage Shift+PgDown Shift+PgDown Shift+PgDown Shift+PgDown
SelectPreviousPage Shift+PgUp Shift+PgUp Shift+PgUp Shift+PgUp
SelectStartOfLine Shift+Home Ctrl+Shift+Left Shift+Home Shift+Home
SelectEndOfLine Shift+End Ctrl+Shift+Right Shift+End Shift+End
SelectStartOfBlock (none) Alt+Shift+Up, Meta+Shift+A (none) (none)
SelectEndOfBlock (none) Alt+Shift+Down, Meta+Shift+E (none) (none)
SelectStartOfDocument Ctrl+Shift+Home Ctrl+Shift+Up, Shift+Home Ctrl+Shift+Home Ctrl+Shift+Home
SelectEndOfDocument Ctrl+Shift+End Ctrl+Shift+Down, Shift+End Ctrl+Shift+End Ctrl+Shift+End
DeleteStartOfWord Ctrl+Backspace Alt+Backspace Ctrl+Backspace Ctrl+Backspace
DeleteEndOfWord Ctrl+Del (none) Ctrl+Del Ctrl+Del
DeleteEndOfLine (none) (none) Ctrl+K Ctrl+K
DeleteCompleteLine (none) (none) Ctrl+U Ctrl+U
InsertParagraphSeparator Enter Enter Enter Enter
InsertLineSeparator Shift+Enter Meta+Enter, Meta+O Shift+Enter Shift+Enter
Backspace (none) Meta+H (none) (none)
Cancel Escape Escape, Ctrl+. Escape Escape

Note that, since the key sequences used for the standard shortcuts differ between platforms, you still need to test your shortcuts on each platform to ensure that you do not unintentionally assign the same key sequence to many actions.

键盘布局问题

Many key sequence specifications are chosen by developers based on the layout of certain types of keyboard, rather than choosing keys that represent the first letter of an action's name, such as Ctrl S ("Ctrl+S") or Ctrl C ("Ctrl+C"). Additionally, because certain symbols can only be entered with the help of modifier keys on certain keyboard layouts, key sequences intended for use with one keyboard layout may map to a different key, map to no keys at all, or require an additional modifier key to be used on different keyboard layouts.

For example, the shortcuts, Ctrl plus and Ctrl minus , are often used as shortcuts for zoom operations in graphics applications, and these may be specified as "Ctrl++" and "Ctrl+-" respectively. However, the way these shortcuts are specified and interpreted depends on the keyboard layout. Users of Norwegian keyboards will note that the + and - keys are not adjacent on the keyboard, but will still be able to activate both shortcuts without needing to press the Shift key. However, users with British keyboards will need to hold down the Shift key to enter the + symbol, making the shortcut effectively the same as "Ctrl+Shift+=".

Although some developers might resort to fully specifying all the modifiers they use on their keyboards to activate a shortcut, this will also result in unexpected behavior for users of different keyboard layouts.

For example, a developer using a British keyboard may decide to specify "Ctrl+Shift+=" as the key sequence in order to create a shortcut that coincidentally behaves in the same way as Ctrl plus 。不管怎样, = key needs to be accessed using the Shift key on Norwegian keyboard, making the required shortcut effectively Ctrl Shift Shift = (an impossible key combination).

As a result, both human-readable strings and hard-coded key codes can both be problematic to use when specifying a key sequence that can be used on a variety of different keyboard layouts. Only the use of 标准快捷键 guarantees that the user will be able to use the shortcuts that the developer intended.

Despite this, we can address this issue by ensuring that human-readable strings are used, making it possible for translations of key sequences to be made for users of different languages. This approach will be successful for users whose keyboards have the most typical layout for the language they are using.

GNU Emacs 样式键序列

Key sequences similar to those used in GNU Emacs , allowing up to four key codes, can be created by using the multiple argument constructor, or by passing a human-readable string of comma-separated key sequences.

例如,键序列, Ctrl X followed by Ctrl C , can be specified using either of the following ways:

QKeySequence(tr("Ctrl+X, Ctrl+C"));
QKeySequence(Qt::CTRL + Qt::Key_X, Qt::CTRL + Qt::Key_C);
					

警告: A QApplication instance must have been constructed before a QKeySequence is created; otherwise, your application may crash.

另请参阅 QShortcut .

成员类型文档编制

enum QKeySequence:: SequenceFormat

常量 描述
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 key sequence 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.

enum QKeySequence:: SequenceMatch

常量 描述
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.

enum QKeySequence:: StandardKey

This enum represent standard key bindings. They can be used to assign platform dependent keyboard shortcuts to a QAction .

Note that the key bindings are platform dependent. The currently bound shortcuts can be queried using keyBindings ().

常量 描述
QKeySequence::AddTab 19 添加新选项卡。
QKeySequence::Back 13 向后导航。
QKeySequence::Backspace 69 删除上一字符。
QKeySequence::Bold 27 加粗文本。
QKeySequence::Close 4 关闭文档/选项卡。
QKeySequence::Copy 9 拷贝。
QKeySequence::Cut 8 剪切。
QKeySequence::Delete 7 删除。
QKeySequence::DeleteEndOfLine 60 删除行尾。
QKeySequence::DeleteEndOfWord 59 Delete word from the end of the cursor.
QKeySequence::DeleteStartOfWord 58 Delete the beginning of a word up to the cursor.
QKeySequence::DeleteCompleteLine 68 Delete the entire line.
QKeySequence::Find 22 在文档中查找。
QKeySequence::FindNext 23 查找下一结果。
QKeySequence::FindPrevious 24 查找上一结果。
QKeySequence::Forward 14 向前导航。
QKeySequence::HelpContents 1 打开帮助内容。
QKeySequence::InsertLineSeparator 62 Insert a new line.
QKeySequence::InsertParagraphSeparator 61 Insert a new paragraph.
QKeySequence::Italic 28 Italic text.
QKeySequence::MoveToEndOfBlock 41 Move cursor to end of block. This shortcut is only used on the macOS.
QKeySequence::MoveToEndOfDocument 43 Move cursor to end of document.
QKeySequence::MoveToEndOfLine 39 移动光标到行尾。
QKeySequence::MoveToNextChar 30 移动光标到下一字符。
QKeySequence::MoveToNextLine 34 移动光标到下一行。
QKeySequence::MoveToNextPage 36 移动光标到下一页。
QKeySequence::MoveToNextWord 32 移动光标到下一单词。
QKeySequence::MoveToPreviousChar 31 移动光标到上一字符。
QKeySequence::MoveToPreviousLine 35 移动光标到上一行。
QKeySequence::MoveToPreviousPage 37 移动光标到上一页。
QKeySequence::MoveToPreviousWord 33 Move cursor to previous word.
QKeySequence::MoveToStartOfBlock 40 Move cursor to start of a block. This shortcut is only used on macOS.
QKeySequence::MoveToStartOfDocument 42 Move cursor to start of document.
QKeySequence::MoveToStartOfLine 38 移动光标到行起始。
QKeySequence::New 6 创建新文档。
QKeySequence::NextChild 20 Navigate to next tab or child window.
QKeySequence::Open 3 打开文档。
QKeySequence::Paste 10 粘贴。
QKeySequence::Preferences 64 打开首选项对话框。
QKeySequence::PreviousChild 21 Navigate to previous tab or child window.
QKeySequence::Print 18 打印文档。
QKeySequence::Quit 65 离开应用程序。
QKeySequence::Redo 12 重做。
QKeySequence::Refresh 15 Refresh or reload current document.
QKeySequence::Replace 25 查找并替换。
QKeySequence::SaveAs 63 Save document after prompting the user for a file name.
QKeySequence::Save 5 保存文档。
QKeySequence::SelectAll 26 选择所有文本。
QKeySequence::Deselect 67 Deselect text. Since 5.1
QKeySequence::SelectEndOfBlock 55 Extend selection to the end of a text block. This shortcut is only used on macOS.
QKeySequence::SelectEndOfDocument 57 Extend selection to end of document.
QKeySequence::SelectEndOfLine 53 Extend selection to end of line.
QKeySequence::SelectNextChar 44 Extend selection to next character.
QKeySequence::SelectNextLine 48 Extend selection to next line.
QKeySequence::SelectNextPage 50 Extend selection to next page.
QKeySequence::SelectNextWord 46 Extend selection to next word.
QKeySequence::SelectPreviousChar 45 Extend selection to previous character.
QKeySequence::SelectPreviousLine 49 Extend selection to previous line.
QKeySequence::SelectPreviousPage 51 Extend selection to previous page.
QKeySequence::SelectPreviousWord 47 Extend selection to previous word.
QKeySequence::SelectStartOfBlock 54 Extend selection to the start of a text block. This shortcut is only used on macOS.
QKeySequence::SelectStartOfDocument 56 Extend selection to start of document.
QKeySequence::SelectStartOfLine 52 Extend selection to start of line.
QKeySequence::Underline 29 下划线文本。
QKeySequence::Undo 11 撤消。
QKeySequence::UnknownKey 0 未绑定键。
QKeySequence::WhatsThis 2 Activate "what's this".
QKeySequence::ZoomIn 16 放大。
QKeySequence::ZoomOut 17 缩小。
QKeySequence::FullScreen 66 Toggle the window state to/from full screen.
QKeySequence::Cancel 70 取消当前操作。

该枚举在 Qt 4.2 引入或被修改。

成员函数文档编制

QKeySequence:: QKeySequence ()

构造空的键序列。

QKeySequence:: QKeySequence (const QString & key , SequenceFormat format = NativeText)

创建键序列从 key 字符串,基于 format .

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 constructor 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.

QKeySequence:: QKeySequence ( int k1 , int k2 = 0, int k3 = 0, int k4 = 0)

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 ,或 Qt::META .

QKeySequence:: QKeySequence (const QKeySequence & keysequence )

Copy constructor. Makes a copy of keysequence .

QKeySequence:: QKeySequence ( StandardKey key )

构造 QKeySequence 对象为给定 key . The result will depend on the currently running platform.

The resulting object will be based on the first element in the list of key bindings for the key .

该函数在 Qt 4.2 引入。

QKeySequence:: ~QKeySequence ()

销毁键序列。

int QKeySequence:: count () const

Returns the number of keys in the key sequence. The maximum is 4.

[static] QKeySequence QKeySequence:: fromString (const QString & str , SequenceFormat format = PortableText)

返回 QKeySequence 从字符串 str 基于 format .

该函数在 Qt 4.1 引入。

另请参阅 toString ().

bool QKeySequence:: isEmpty () const

返回 true 若键序列为空;否则返回 false。

[static] QList < QKeySequence > QKeySequence:: keyBindings ( StandardKey key )

Returns a list of key bindings for the given key . The result of calling this function will vary based on the target platform. The first element of the list indicates the primary shortcut for the given platform. If the result contains more than one result, these can be considered alternative shortcuts on the same platform for the given key .

该函数在 Qt 4.2 引入。

[static] QList < QKeySequence > QKeySequence:: listFromString (const QString & str , SequenceFormat format = PortableText)

返回列表化的 QKeySequence 从字符串 str 基于 format .

该函数在 Qt 5.1 引入。

另请参阅 fromString () 和 listToString ().

[static] QString QKeySequence:: listToString (const QList < QKeySequence > & list , SequenceFormat format = PortableText)

返回字符串表示为 list 基于 format .

该函数在 Qt 5.1 引入。

另请参阅 toString () 和 listFromString ().

SequenceMatch QKeySequence:: matches (const QKeySequence & seq ) const

匹配序列同 seq 。返回 ExactMatch 若成功, PartialMatch if seq 匹配不完整,和 NoMatch if the sequences have nothing in common. Returns NoMatch if seq is shorter.

[static] QKeySequence QKeySequence:: mnemonic (const QString & text )

Returns the shortcut key sequence for the mnemonic in text , or an empty key sequence if no mnemonics are found.

例如,mnemonic("E&xit") 返回 Qt::ALT+Qt::Key_X ,mnemonic("&Quit") 返回 ALT+Key_Q ,而 mnemonic("Quit") 返回空 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.

void QKeySequence:: swap ( QKeySequence & other )

交换键序列 other 与此键序列。此操作非常快且从不失败。

该函数在 Qt 4.8 引入。

QString QKeySequence:: toString ( SequenceFormat format = PortableText) const

返回键序列的字符串表示,基于 format .

例如,值 Qt::CTRL + Qt::Key_O 结果为 Ctrl+O。若键序列拥有多个键代码,则以逗号分隔返回字符串中的各个键代码 (譬如 Alt+X, Ctrl+Y, Z)。字符串 Ctrl、Shift 等的翻译是使用 QObject::tr () 在 QShortcut 上下文。

若键序列没有键,则返回空字符串。

On macOS, the string returned resembles the sequence that is shown in the menu bar if format is QKeySequence::NativeText ;否则,字符串使用 portable (可移植) 格式,适合写入文件。

该函数在 Qt 4.1 引入。

另请参阅 fromString ().

QKeySequence:: operator QVariant () const

Returns the key sequence as a QVariant

bool QKeySequence:: operator!= (const QKeySequence & other ) const

返回 true 若此键序列不等于 other 键序列;否则返回 false .

bool QKeySequence:: operator< (const QKeySequence & other ) const

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.

此函数在某些情况下很有用,例如,若想要使用 QKeySequence 对象作为键在 QMap .

另请参阅 operator== (), operator!= (), operator> (), operator<= (),和 operator>= ().

bool QKeySequence:: operator<= (const QKeySequence & other ) const

返回 true if this key sequence is smaller or equal to the other 键序列;否则返回 false .

另请参阅 operator== (), operator!= (), operator< (), operator> (),和 operator>= ().

QKeySequence &QKeySequence:: operator= (const QKeySequence & other )

Assignment operator. Assigns the other key sequence to this object.

QKeySequence &QKeySequence:: operator= ( QKeySequence && other )

移动赋值 other 到此 QKeySequence 实例。

该函数在 Qt 5.2 引入。

bool QKeySequence:: operator== (const QKeySequence & other ) const

返回 true if this key sequence is equal to the other 键序列;否则返回 false .

bool QKeySequence:: operator> (const QKeySequence & other ) const

返回 true if this key sequence is larger than the other 键序列;否则返回 false .

另请参阅 operator== (), operator!= (), operator< (), operator<= (),和 operator>= ().

bool QKeySequence:: operator>= (const QKeySequence & other ) const

返回 true if this key sequence is larger or equal to the other 键序列;否则返回 false .

另请参阅 operator== (), operator!= (), operator< (), operator> (),和 operator<= ().

int QKeySequence:: operator[] ( uint index ) const

Returns a reference to the element at position index in the key sequence. This can only be used to read an element.

相关非成员

void qt_set_sequence_auto_mnemonic ( bool b )

Specifies whether mnemonics for menu items, labels, etc., should be honored or not. On Windows and X11, this feature is on by default; on macOS, it is off. When this feature is off (that is, when b is false), QKeySequence::mnemonic () always returns an empty string.

注意: This function is not declared in any of Qt's header files. To use it in your application, declare the function prototype before calling it.

另请参阅 QShortcut .

QDataStream & operator<< ( QDataStream & stream , const QKeySequence & sequence )

Writes the key sequence stream .

另请参阅 QDataStream 运算符格式 .

QDataStream & operator>> ( QDataStream & stream , QKeySequence & sequence )

Reads a key sequence from the stream into the key sequence .

另请参阅 QDataStream 运算符格式 .