QKeySequence(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

πŸ’– NAME πŸ’–

QKeySequence β€” bestie, it's the class that encapsulates a key sequence as used by accelerators. That's the whole job description. Iconic, honestly. πŸŽ€


✨ SYNOPSIS ✨

#include <qkeysequence.h>

It Inherits Qt. Yeah. The whole thing. πŸ‘‘

🫢 Public Members 🫢

QKeySequence ()
QKeySequence ( const QString & key )
QKeySequence ( int key )
QKeySequence ( int k1, int k2, int k3 = 0, int k4 = 0 )
QKeySequence ( const QKeySequence & keysequence )
~QKeySequence ()
uint count () const
bool isEmpty () const
Qt::SequenceMatch matches ( const QKeySequence & seq ) const
operator QString () const
operator int () const  (obsolete)
int operator[] ( uint index ) const
QKeySequence & operator= ( const QKeySequence & keysequence )
bool operator== ( const QKeySequence & keysequence ) const
bool operator!= ( const QKeySequence & keysequence ) const
QDataStream & operator<< ( QDataStream & s, const QKeySequence & keysequence )
QDataStream & operator>> ( QDataStream & s, QKeySequence & keysequence )

🌸 DESCRIPTION 🌸

The QKeySequence class encapsulates a key sequence as used by accelerators. No cap, that's literally the line.

A key sequence is made of up to four keyboard codes, and each one can optionally be combined with modifiers β€” like SHIFT, CTRL, ALT, META, or UNICODE_ACCEL. So for example, CTRL + Key_P might be the sequence you use as a shortcut for printing a document. The key codes are all listed in qnamespace.h. And if you wanna go the other way? Use UNICODE_ACCEL with the unicode code point of the character. For example, UNICODE_ACCEL + 'A' gives the same key sequence as Key_A. Slay. πŸ’…

You can build key sequences either from an integer key code, or from a human readable translatable string like "Ctrl+X,Alt+Space". And you can cast a key sequence to a QString to get a human readable translated version of the sequence. The translations happen in the "QAccel" context.

See also QAccel and Miscellaneous Classes.


🧚 MEMBER FUNCTION DOCUMENTATION 🧚

QKeySequence::QKeySequence ()

Constructs an empty key sequence. Nothing in it. Void. Empty nest era. 🫧

QKeySequence::QKeySequence ( const QString & key )

Creates a key sequence from the string key. For example "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl", "Shift", "Alt" and "Meta" are recognized, along with their translated equivalents in the "QAccel" context (using QObject::tr()).

You can enter multiple key codes (up to four) by separating them with commas, e.g. "Alt+X,Ctrl+S,Q".

This constructor is typically used with tr(), so that accelerator keys can be replaced in translations:

QPopupMenu *file = new QPopupMenu( this );
file->insertItem( tr("&Open..."), this, SLOT(open()),
                  QKeySequence( tr("Ctrl+O", "File|Open") ) );

Notice the "File|Open" translator comment. It is by no means necessary, but it gives the human translator some context. Be nice to the translators, bestie. 🫢

QKeySequence::QKeySequence ( int key )

Constructs a key sequence that has a single key.

The key codes are listed in qnamespace.h and can be combined with modifiers, e.g. with SHIFT, CTRL, ALT, META or UNICODE_ACCEL.

QKeySequence::QKeySequence ( int k1, int k2, 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 qnamespace.h and can be combined with modifiers, e.g. with SHIFT, CTRL, ALT, META or UNICODE_ACCEL.

QKeySequence::QKeySequence ( const QKeySequence & keysequence )

Copy constructor. Makes a copy of keysequence. Dupe it, queen. πŸ‘―

QKeySequence::~QKeySequence ()

Destroys the key sequence. Gone. Poof. πŸ’€

uint QKeySequence::count () const

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

bool QKeySequence::isEmpty () const

Returns TRUE if the key sequence is empty; otherwise returns FALSE.

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

Matches the sequence with seq. Returns Qt::Identical if it's a success, Qt::PartialMatch for a matching but incomplete seq, and Qt::NoMatch if the sequences have nothing in common. Also returns Qt::NoMatch if seq is shorter.

QKeySequence::operator QString () const

Creates an accelerator string for the key sequence. For instance CTRL+Key_O gives "Ctrl+O". If the key sequence has multiple key codes they're returned comma-separated, e.g. "Alt+X, Ctrl+Y, Z". The strings "Ctrl", "Shift", etc. are translated (using QObject::tr()) in the "QAccel" scope. If the key sequence has no keys, QString::null is returned.

On Mac OS X, the string returned resembles the sequence that is shown in the menubar. Cute. ✨

QKeySequence::operator int () const

⚠️ This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code. Periodt.

For backward compatibility: returns the first keycode as integer. If the key sequence is empty, 0 is returned.

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

Returns TRUE if keysequence is not equal to this key sequence; otherwise returns FALSE.

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

Assignment operator. Assigns keysequence to this object.

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

Returns TRUE if keysequence is equal to this key sequence; otherwise returns FALSE.

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. Read-only era. πŸ™ˆ


QDataStream & operator<< ( QDataStream & s, const QKeySequence & keysequence )

Writes the key sequence keysequence to the stream s.

See also Format of the QDataStream operators.

QDataStream & operator>> ( QDataStream & s, QKeySequence & keysequence )

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

See also Format of the QDataStream operators.


🌈 SEE ALSO 🌈


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

πŸ¦‹ AUTHOR πŸ¦‹

Generated automatically from the source code. (No human author to thank, it just spawned like that. πŸ’«)

πŸ’€ BUGS πŸ’€

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. 🫢

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qkeysequence.3qt) and the Qt version (3.3.8).


okay that's the whole thing, you made it to the end bestie, I'm so proud of you πŸŽ€ this lil man page came from Trolltech AS, dated 2 February 2007, and it's the QKeySequence(3qt) page for Qt 3.3.8. mwah. πŸ’–

πŸ“¦ where this page comes from