Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QKeySequence Class Reference

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

#include <qkeysequence.h>

+ Collaboration diagram for QKeySequence:

Public Types

enum  StandardKey {
  UnknownKey , HelpContents , WhatsThis , Open ,
  Close , Save , New , Delete ,
  Cut , Copy , Paste , Undo ,
  Redo , Back , Forward , Refresh ,
  ZoomIn , ZoomOut , Print , AddTab ,
  NextChild , PreviousChild , Find , FindNext ,
  FindPrevious , Replace , SelectAll , Bold ,
  Italic , Underline , MoveToNextChar , MoveToPreviousChar ,
  MoveToNextWord , MoveToPreviousWord , MoveToNextLine , MoveToPreviousLine ,
  MoveToNextPage , MoveToPreviousPage , MoveToStartOfLine , MoveToEndOfLine ,
  MoveToStartOfBlock , MoveToEndOfBlock , MoveToStartOfDocument , MoveToEndOfDocument ,
  SelectNextChar , SelectPreviousChar , SelectNextWord , SelectPreviousWord ,
  SelectNextLine , SelectPreviousLine , SelectNextPage , SelectPreviousPage ,
  SelectStartOfLine , SelectEndOfLine , SelectStartOfBlock , SelectEndOfBlock ,
  SelectStartOfDocument , SelectEndOfDocument , DeleteStartOfWord , DeleteEndOfWord ,
  DeleteEndOfLine , InsertParagraphSeparator , InsertLineSeparator , SaveAs ,
  Preferences , Quit , FullScreen , Deselect ,
  DeleteCompleteLine , Backspace , Cancel
}
 
enum  SequenceFormat { NativeText , PortableText }
 \value NativeText The key sequence as a platform specific string. More...
 
enum  SequenceMatch { NoMatch , PartialMatch , ExactMatch }
 \value NoMatch The key sequences are different; not even partially matching. More...
 
typedef QKeySequencePrivateDataPtr
 

Public Member Functions

 QKeySequence ()
 Constructs an empty key sequence.
 
 QKeySequence (const QString &key, SequenceFormat format=NativeText)
 Creates a key sequence from the key string, based on format.
 
 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.
 
 QKeySequence (QKeyCombination k1, QKeyCombination k2=QKeyCombination::fromCombined(0), QKeyCombination k3=QKeyCombination::fromCombined(0), QKeyCombination k4=QKeyCombination::fromCombined(0))
 Constructs a key sequence with up to 4 keys k1, k2, k3 and k4.
 
 QKeySequence (const QKeySequence &ks)
 Copy constructor.
 
 QKeySequence (StandardKey key)
 
 ~QKeySequence ()
 Destroys the key sequence.
 
int count () const
 Returns the number of keys in the key sequence.
 
bool isEmpty () const
 Returns true if the key sequence is empty; otherwise returns false.
 
 Q_ENUM (SequenceMatch)
 
QString toString (SequenceFormat format=PortableText) const
 
SequenceMatch matches (const QKeySequence &seq) const
 Matches the sequence with seq.
 
 operator QVariant () const
 Returns the key sequence as a QVariant.
 
QKeyCombination operator[] (uint i) const
 Returns a reference to the element at position index in the key sequence.
 
QKeySequenceoperator= (const QKeySequence &other)
 Move-assigns other to this QKeySequence instance.
 
void swap (QKeySequence &other) noexcept
 
bool operator== (const QKeySequence &other) const
 Returns true if this key sequence is equal to the other key sequence; otherwise returns false.
 
bool operator!= (const QKeySequence &other) const
 Returns true if this key sequence is not equal to the other key sequence; otherwise returns false.
 
bool operator< (const QKeySequence &ks) const
 Provides an arbitrary comparison of this key sequence and other key sequence.
 
bool operator> (const QKeySequence &other) const
 Returns true if this key sequence is larger than the other key sequence; otherwise returns false.
 
bool operator<= (const QKeySequence &other) const
 Returns true if this key sequence is smaller or equal to the other key sequence; otherwise returns false.
 
bool operator>= (const QKeySequence &other) const
 Returns true if this key sequence is larger or equal to the other key sequence; otherwise returns false.
 
bool isDetached () const
 
DataPtrdata_ptr ()
 

Static Public Member Functions

static QKeySequence fromString (const QString &str, SequenceFormat format=PortableText)
 
static QList< QKeySequencelistFromString (const QString &str, SequenceFormat format=PortableText)
 
static QString listToString (const QList< QKeySequence > &list, SequenceFormat format=PortableText)
 
static 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.
 
static QList< QKeySequencekeyBindings (StandardKey key)
 

Friends

class QShortcutMap
 
class QShortcut
 
Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &in, const QKeySequence &ks)
 Writes the key sequence to the stream.
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &in, QKeySequence &ks)
 Reads a key sequence from the stream into the key sequence.
 
Q_GUI_EXPORT size_t qHash (const QKeySequence &key, size_t seed) noexcept
 

Related Symbols

(Note that these are not member symbols.)

void qt_set_sequence_auto_mnemonic (bool b)
 Specifies whether mnemonics for menu items, labels, etc., should be honored or not.
 
size_t qHash (const QKeySequence &key, size_t seed) noexcept
 
QDataStreamoperator<< (QDataStream &stream, const QKeySequence &sequence)
 Writes the key sequence to the stream.
 
QDataStreamoperator>> (QDataStream &stream, QKeySequence &sequence)
 Reads a key sequence from the stream into the key sequence.
 

Detailed Description

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

\inmodule QtGui

In its most common form, a key sequence describes a combination of keys that must be used together to perform some action. Key sequences are used with QAction objects to specify which keyboard shortcuts can be used to trigger actions.

Key sequences can be constructed for use as keyboard shortcuts in three different ways:

\list

  • For standard shortcuts, a \l{QKeySequence::StandardKey}{standard key} can be used to request the platform-specific key sequence associated with each shortcut.
  • For custom shortcuts, human-readable strings such as "Ctrl+X" can be used, and these can be translated into the appropriate shortcuts for users of different languages. Translations are made in the "QShortcut" context.
  • For hard-coded shortcuts, integer key codes can be specified with a combination of values defined by the Qt::Key and Qt::KeyboardModifier enum values. Each key code consists of a single Qt::Key value and zero or more modifiers, such as Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifier and Qt::MetaModifier. \endlist

For example, \uicontrol{Ctrl P} might be a sequence used as a shortcut for printing a document, and can be specified in any of the following ways:

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

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 \uicontrol{Shift} key to activate a shortcut specified with "Ctrl+P". However, for other keys, the use of \uicontrol{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 \l{Keyboard Layout Issues} 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 Apple platforms, 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.

Note
On Apple platforms, references to "Ctrl", Qt::CTRL, Qt::Key_Control and Qt::ControlModifier correspond to the \uicontrol Command keys on the Macintosh keyboard, and references to "Meta", Qt::META, Qt::Key_Meta and Qt::MetaModifier correspond to the \uicontrol Control keys. In effect, developers can use the same shortcut descriptions across all platforms, and their applications will automatically work as expected on Apple platforms.

Definition at line 34 of file qkeysequence.h.

Member Typedef Documentation

◆ DataPtr

Definition at line 183 of file qkeysequence.h.

Member Enumeration Documentation

◆ SequenceFormat

\value NativeText The key sequence as a platform specific string.

This means that it will be shown translated and on Apple platforms 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.

\value PortableText 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.

Enumerator
NativeText 
PortableText 

Definition at line 114 of file qkeysequence.h.

◆ SequenceMatch

\value NoMatch The key sequences are different; not even partially matching.

\value PartialMatch The key sequences match partially, but are not the same. \value ExactMatch The key sequences are the same.

Enumerator
NoMatch 
PartialMatch 
ExactMatch 

Definition at line 134 of file qkeysequence.h.

◆ StandardKey

Since
4.2

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().

\value AddTab Add new tab. \value Back Navigate back. \value Backspace Delete previous character. \value Bold Bold text. \value Close Close document/tab. \value Copy Copy. \value Cut Cut. \value Delete Delete. \value DeleteEndOfLine Delete end of line. \value DeleteEndOfWord Delete word from the end of the cursor. \value DeleteStartOfWord Delete the beginning of a word up to the cursor. \value DeleteCompleteLine Delete the entire line. \value Find Find in document. \value FindNext Find next result. \value FindPrevious Find previous result. \value Forward Navigate forward. \value HelpContents Open help contents. \value InsertLineSeparator Insert a new line. \value InsertParagraphSeparator Insert a new paragraph. \value Italic Italic text. \value MoveToEndOfBlock Move cursor to end of block. This shortcut is only used on Apple platforms. \value MoveToEndOfDocument Move cursor to end of document. \value MoveToEndOfLine Move cursor to end of line. \value MoveToNextChar Move cursor to next character. \value MoveToNextLine Move cursor to next line. \value MoveToNextPage Move cursor to next page. \value MoveToNextWord Move cursor to next word. \value MoveToPreviousChar Move cursor to previous character. \value MoveToPreviousLine Move cursor to previous line. \value MoveToPreviousPage Move cursor to previous page. \value MoveToPreviousWord Move cursor to previous word. \value MoveToStartOfBlock Move cursor to start of a block. This shortcut is only used on Apple platforms. \value MoveToStartOfDocument Move cursor to start of document. \value MoveToStartOfLine Move cursor to start of line. \value New Create new document. \value NextChild Navigate to next tab or child window. \value Open Open document. \value Paste Paste. \value Preferences Open the preferences dialog. \value PreviousChild Navigate to previous tab or child window. \value Print Print document. \value Quit Quit the application. \value Redo Redo. \value Refresh Refresh or reload current document. \value Replace Find and replace. \value SaveAs Save document after prompting the user for a file name. \value Save Save document. \value SelectAll Select all text. \value Deselect Deselect text. Since 5.1 \value SelectEndOfBlock Extend selection to the end of a text block. This shortcut is only used on Apple platforms. \value SelectEndOfDocument Extend selection to end of document. \value SelectEndOfLine Extend selection to end of line. \value SelectNextChar Extend selection to next character. \value SelectNextLine Extend selection to next line. \value SelectNextPage Extend selection to next page. \value SelectNextWord Extend selection to next word. \value SelectPreviousChar Extend selection to previous character. \value SelectPreviousLine Extend selection to previous line. \value SelectPreviousPage Extend selection to previous page. \value SelectPreviousWord Extend selection to previous word. \value SelectStartOfBlock Extend selection to the start of a text block. This shortcut is only used on Apple platforms. \value SelectStartOfDocument Extend selection to start of document. \value SelectStartOfLine Extend selection to start of line. \value Underline Underline text. \value Undo Undo. \value UnknownKey Unbound key. \value WhatsThis Activate "what's this". \value ZoomIn Zoom in. \value ZoomOut Zoom out. \value FullScreen Toggle the window state to/from full screen. \value Cancel Cancel the current operation.

Enumerator
UnknownKey 
HelpContents 
WhatsThis 
Open 
Close 
Save 
New 
Delete 
Cut 
Copy 
Paste 
Undo 
Redo 
Back 
Forward 
Refresh 
ZoomIn 
ZoomOut 
Print 
AddTab 
NextChild 
PreviousChild 
Find 
FindNext 
FindPrevious 
Replace 
SelectAll 
Bold 
Italic 
Underline 
MoveToNextChar 
MoveToPreviousChar 
MoveToNextWord 
MoveToPreviousWord 
MoveToNextLine 
MoveToPreviousLine 
MoveToNextPage 
MoveToPreviousPage 
MoveToStartOfLine 
MoveToEndOfLine 
MoveToStartOfBlock 
MoveToEndOfBlock 
MoveToStartOfDocument 
MoveToEndOfDocument 
SelectNextChar 
SelectPreviousChar 
SelectNextWord 
SelectPreviousWord 
SelectNextLine 
SelectPreviousLine 
SelectNextPage 
SelectPreviousPage 
SelectStartOfLine 
SelectEndOfLine 
SelectStartOfBlock 
SelectEndOfBlock 
SelectStartOfDocument 
SelectEndOfDocument 
DeleteStartOfWord 
DeleteEndOfWord 
DeleteEndOfLine 
InsertParagraphSeparator 
InsertLineSeparator 
SaveAs 
Preferences 
Quit 
FullScreen 
Deselect 
DeleteCompleteLine 
Backspace 
Cancel 

Definition at line 39 of file qkeysequence.h.

Constructor & Destructor Documentation

◆ QKeySequence() [1/6]

QKeySequence::QKeySequence ( )

Constructs an empty key sequence.

Definition at line 799 of file qkeysequence.cpp.

References QBasicAtomicInteger< T >::ref(), and QKeySequencePrivate::ref.

Referenced by fromString(), and mnemonic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ QKeySequence() [2/6]

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

Creates a key sequence from the key string, based on 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 \l{QObject::tr()}{tr}(), so that shortcut keys can be replaced in translations:

QMenu *file = new QMenu(this);
file->addAction(tr("&Open..."), QKeySequence(tr("Ctrl+O", "File|Open")),
this, &MainWindow::open);

Note the "File|Open" translator comment. It is by no means necessary, but it provides some context for the human translator.

Definition at line 825 of file qkeysequence.cpp.

◆ QKeySequence() [3/6]

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::KeyboardModifier) such as Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifier, or Qt::MetaModifier.

Definition at line 840 of file qkeysequence.cpp.

References k1, and QKeySequencePrivate::key.

◆ QKeySequence() [4/6]

Constructs a key sequence with up to 4 keys k1, k2, k3 and k4.

See also
QKeyCombination

Definition at line 855 of file qkeysequence.cpp.

◆ QKeySequence() [5/6]

QKeySequence::QKeySequence ( const QKeySequence & keysequence)

Copy constructor.

Makes a copy of keysequence.

Definition at line 863 of file qkeysequence.cpp.

References QBasicAtomicInteger< T >::ref(), and QKeySequencePrivate::ref.

+ Here is the call graph for this function:

◆ QKeySequence() [6/6]

QKeySequence::QKeySequence ( StandardKey key)
Since
4.2

Constructs a QKeySequence object for the given 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.

Definition at line 783 of file qkeysequence.cpp.

References keyBindings(), QBasicAtomicInteger< T >::ref(), and QKeySequencePrivate::ref.

+ Here is the call graph for this function:

◆ ~QKeySequence()

QKeySequence::~QKeySequence ( )

Destroys the key sequence.

Definition at line 886 of file qkeysequence.cpp.

References QBasicAtomicInteger< T >::deref(), and QKeySequencePrivate::ref.

+ Here is the call graph for this function:

Member Function Documentation

◆ count()

int QKeySequence::count ( ) const

Returns the number of keys in the key sequence.

The maximum is 4.

Definition at line 911 of file qkeysequence.cpp.

References QKeySequencePrivate::key, and QKeySequencePrivate::MaxKeyCount.

Referenced by QDBusMenuItem::convertKeySequence(), QMacStyle::drawControl(), matches(), QAndroidInputContext::sendShortcut(), QKeySequenceEdit::setKeySequence(), QCocoaMenuItem::sync(), and toString().

+ Here is the caller graph for this function:

◆ data_ptr()

DataPtr & QKeySequence::data_ptr ( )
inline

Definition at line 184 of file qkeysequence.h.

References d.

◆ fromString()

QKeySequence QKeySequence::fromString ( const QString & str,
SequenceFormat format = PortableText )
static
Since
4.1

Return a QKeySequence from the string str based on format.

See also
toString()

Definition at line 1520 of file qkeysequence.cpp.

References QKeySequence(), and str.

Referenced by QMacStyle::drawControl(), QWasmInputContext::inputStringChanged(), listFromString(), QQuickLabsPlatformMenuItem::sync(), valueToKeySequence(), and valueToKeySequences().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isDetached()

bool QKeySequence::isDetached ( ) const

Definition at line 1473 of file qkeysequence.cpp.

References QBasicAtomicInteger< T >::loadRelaxed(), and QKeySequencePrivate::ref.

+ Here is the call graph for this function:

◆ isEmpty()

bool QKeySequence::isEmpty ( ) const

Returns true if the key sequence is empty; otherwise returns false.

Definition at line 921 of file qkeysequence.cpp.

References QKeySequencePrivate::key.

Referenced by QShortcutMap::addShortcut(), QWindowsMenuItem::formatDebug(), QGraphicsWidget::grabShortcut(), QMenu::initStyleOption(), QWindowsMenuItem::nativeText(), QShortcutMap::removeShortcut(), QShortcutMap::setShortcutAutoRepeat(), QShortcutMap::setShortcutEnabled(), and QMenuPrivate::updateActionRects().

+ Here is the caller graph for this function:

◆ keyBindings()

QList< QKeySequence > QKeySequence::keyBindings ( StandardKey key)
static
Since
4.2

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.

Definition at line 878 of file qkeysequence.cpp.

References QGuiApplicationPrivate::platformTheme().

Referenced by QKeySequence(), QShortcut::QShortcut(), QShortcut::setKeys(), valueToKeySequence(), and valueToKeySequences().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listFromString()

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

Return a list of QKeySequence from the string str based on format.

See also
fromString()
listToString()

Definition at line 1533 of file qkeysequence.cpp.

References fromString(), QString::split(), and str.

+ Here is the call graph for this function:

◆ listToString()

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

Return a string representation of list based on format.

See also
toString()
listFromString()

Definition at line 1554 of file qkeysequence.cpp.

References list.

◆ matches()

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

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.

Definition at line 1335 of file qkeysequence.cpp.

References count(), ExactMatch, i, match(), NoMatch, and PartialMatch.

+ Here is the call graph for this function:

◆ mnemonic()

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

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.

Definition at line 935 of file qkeysequence.cpp.

References QKeySequence(), Qt::ALT, QString::at(), QString::indexOf(), qPrintable, qt_sequence_no_mnemonics, qWarning, ret, QString::size(), and text.

Referenced by QQuickAbstractButton::buttonChange(), QTabBar::insertTab(), QMenu::keyPressEvent(), QQuickMenu::keyPressEvent(), QTabBar::setTabText(), QAbstractButton::setText(), QGroupBox::setTitle(), QMenuBarPrivate::updateGeometries(), and QLabelPrivate::updateShortcut().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator QVariant()

QKeySequence::operator QVariant ( ) const

Returns the key sequence as a QVariant.

Definition at line 1359 of file qkeysequence.cpp.

References QVariant::fromValue().

+ Here is the call graph for this function:

◆ operator!=()

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

Returns true if this key sequence is not equal to the other key sequence; otherwise returns false.

Definition at line 158 of file qkeysequence.h.

References other().

+ Here is the call graph for this function:

◆ operator<()

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.

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<=(), operator>=()

Definition at line 1437 of file qkeysequence.cpp.

References QKeySequencePrivate::key, QKeySequencePrivate::MaxKeyCount, and other().

+ Here is the call graph for this function:

◆ operator<=()

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

Returns true if this key sequence is smaller or equal to the other key sequence; otherwise returns false.

See also
operator==(), operator!=(), operator<(), operator>(), operator>=()

Definition at line 163 of file qkeysequence.h.

References other().

+ Here is the call graph for this function:

◆ operator=()

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

Move-assigns other to this QKeySequence instance.

Assignment operator.

Since
5.2

Assigns the other key sequence to this object.

Definition at line 1379 of file qkeysequence.cpp.

References other(), and qAtomicAssign().

+ Here is the call graph for this function:

◆ operator==()

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

Returns true if this key sequence is equal to the other key sequence; otherwise returns false.

Definition at line 1405 of file qkeysequence.cpp.

References QKeySequencePrivate::key, and other().

+ Here is the call graph for this function:

◆ operator>()

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

Returns true if this key sequence is larger than the other key sequence; otherwise returns false.

See also
operator==(), operator!=(), operator<(), operator<=(), operator>=()

Definition at line 161 of file qkeysequence.h.

References other().

+ Here is the call graph for this function:

◆ operator>=()

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

Returns true if this key sequence is larger or equal to the other key sequence; otherwise returns false.

See also
operator==(), operator!=(), operator<(), operator>(), operator<=()

Definition at line 165 of file qkeysequence.h.

References other().

+ Here is the call graph for this function:

◆ operator[]()

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

Definition at line 1368 of file qkeysequence.cpp.

References QKeyCombination::fromCombined(), QKeySequencePrivate::key, QKeySequencePrivate::MaxKeyCount, and Q_ASSERT_X.

+ Here is the call graph for this function:

◆ Q_ENUM()

QKeySequence::Q_ENUM ( SequenceMatch )

◆ swap()

void QKeySequence::swap ( QKeySequence & other)
inlinenoexcept
Since
4.8

Swaps key sequence other with this key sequence. This operation is very fast and never fails.

Definition at line 155 of file qkeysequence.h.

References d, other(), and qt_ptr_swap().

+ Here is the call graph for this function:

◆ toString()

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

Return a string representation of the key sequence, based on format.

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" context.

If the key sequence has no keys, an empty string is returned.

On Apple platforms, the string returned resembles the sequence that is shown in the menu bar if format is QKeySequence::NativeText; otherwise, the string uses the "portable" format, suitable for writing to a file.

See also
fromString()

Definition at line 1499 of file qkeysequence.cpp.

References count(), QKeySequencePrivate::encodeString(), QKeyCombination::fromCombined(), i, and QKeySequencePrivate::key.

Referenced by QMenu::initStyleOption(), QWindowsMenuItem::nativeText(), QQuickShortcut::nativeText(), QQuickShortcut::portableText(), QKeySequenceEditPrivate::resetState(), QCocoaMenuItem::sync(), QQuickLabsPlatformMenuItem::sync(), and QMenuPrivate::updateActionRects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator<< [1/2]

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

Writes the key sequence to the stream.

See also
{Serializing Qt Data Types}{Format of the QDataStream operators}

Definition at line 1579 of file qkeysequence.cpp.

◆ operator<<() [2/2]

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

Writes the key sequence to the stream.

See also
{Serializing Qt Data Types}{Format of the QDataStream operators}

Definition at line 1579 of file qkeysequence.cpp.

◆ operator>> [1/2]

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

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

See also
{Serializing Qt Data Types}{Format of the QDataStream operators}

Definition at line 1601 of file qkeysequence.cpp.

◆ operator>>() [2/2]

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

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

See also
{Serializing Qt Data Types}{Format of the QDataStream operators}

Definition at line 1601 of file qkeysequence.cpp.

◆ qHash() [1/2]

size_t qHash ( const QKeySequence & key,
size_t seed )
related
Since
5.6

Calculates the hash value of key, using seed to seed the calculation.

Definition at line 1420 of file qkeysequence.cpp.

◆ qHash [2/2]

size_t qHash ( const QKeySequence & key,
size_t seed = 0 )
friend
Since
5.6

Calculates the hash value of key, using seed to seed the calculation.

Definition at line 1420 of file qkeysequence.cpp.

◆ QShortcut

friend class QShortcut
friend

Definition at line 180 of file qkeysequence.h.

◆ QShortcutMap

friend class QShortcutMap
friend

Definition at line 179 of file qkeysequence.h.

◆ qt_set_sequence_auto_mnemonic()

void qt_set_sequence_auto_mnemonic ( bool b)
related

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.

Note
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.
See also
QShortcut

Definition at line 139 of file qkeysequence.cpp.

References qt_sequence_no_mnemonics.


The documentation for this class was generated from the following files: