Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QShortcut Class Reference

The QShortcut class is used to create keyboard shortcuts. More...

#include <qshortcut.h>

+ Inheritance diagram for QShortcut:
+ Collaboration diagram for QShortcut:

Signals

void activated ()
 This signal is emitted when the user types the shortcut's key sequence.
 
void activatedAmbiguously ()
 When a key sequence is being typed at the keyboard, it is said to be ambiguous as long as it matches the start of more than one shortcut.
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

 QShortcut (QObject *parent)
 Constructs a QShortcut object for the parent, which should be a QWindow or a QWidget.
 
 QShortcut (const QKeySequence &key, QObject *parent, const char *member=nullptr, const char *ambiguousMember=nullptr, Qt::ShortcutContext context=Qt::WindowShortcut)
 Constructs a QShortcut object for the parent, which should be a QWindow or a QWidget.
 
 QShortcut (QKeySequence::StandardKey key, QObject *parent, const char *member=nullptr, const char *ambiguousMember=nullptr, Qt::ShortcutContext context=Qt::WindowShortcut)
 
template<typename Func1 >
 QShortcut (const QKeySequence &key, QObject *parent, Func1 slot1, Qt::ShortcutContext context=Qt::WindowShortcut)
 
template<class Obj1 , typename Func1 >
 QShortcut (const QKeySequence &key, QObject *parent, const Obj1 *object1, Func1 slot1, Qt::ShortcutContext context=Qt::WindowShortcut, typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type *=0)
 
template<class Obj1 , typename Func1 , typename Func2 >
 QShortcut (const QKeySequence &key, QObject *parent, const Obj1 *object1, Func1 slot1, Func2 slot2, Qt::ShortcutContext context=Qt::WindowShortcut, typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type *=0)
 
template<class Obj1 , typename Func1 , class Obj2 , typename Func2 >
 QShortcut (const QKeySequence &key, QObject *parent, const Obj1 *object1, Func1 slot1, const Obj2 *object2, Func2 slot2, Qt::ShortcutContext context=Qt::WindowShortcut, typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type *=0, typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj2 * >::Value >::type *=0)
 
template<typename Func1 >
 QShortcut (QKeySequence::StandardKey key, QObject *parent, Func1 slot1, Qt::ShortcutContext context=Qt::WindowShortcut)
 
template<class Obj1 , typename Func1 >
 QShortcut (QKeySequence::StandardKey key, QObject *parent, const Obj1 *object1, Func1 slot1, Qt::ShortcutContext context=Qt::WindowShortcut, typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type *=0)
 
template<class Obj1 , typename Func1 , typename Func2 >
 QShortcut (QKeySequence::StandardKey key, QObject *parent, const Obj1 *object1, Func1 slot1, Func2 slot2, Qt::ShortcutContext context=Qt::WindowShortcut, typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type *=0)
 
template<class Obj1 , typename Func1 , class Obj2 , typename Func2 >
 QShortcut (QKeySequence::StandardKey key, QObject *parent, const Obj1 *object1, Func1 slot1, const Obj2 *object2, Func2 slot2, Qt::ShortcutContext context=Qt::WindowShortcut, typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type *=0, typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj2 * >::Value >::type *=0)
 
 ~QShortcut ()
 Destroys the shortcut.
 
void setKey (const QKeySequence &key)
 
QKeySequence key () const
 
void setKeys (QKeySequence::StandardKey key)
 Sets the triggers to those matching the standard key key.
 
void setKeys (const QList< QKeySequence > &keys)
 Sets keys as the list of key sequences that trigger the shortcut.
 
QList< QKeySequencekeys () const
 Returns the list of key sequences which trigger this shortcut.
 
void setEnabled (bool enable)
 
bool isEnabled () const
 
void setContext (Qt::ShortcutContext context)
 
Qt::ShortcutContext context () const
 
void setAutoRepeat (bool on)
 
bool autoRepeat () const
 
void setWhatsThis (const QString &text)
 Sets the shortcut's "What's This?" help text.
 
QString whatsThis () const
 Returns the shortcut's "What's This?" help text.
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Protected Member Functions

bool event (QEvent *e) override
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Properties

QKeySequence key
 the shortcut's primary key sequence
 
bool enabled
 whether the shortcut is enabled
 
bool autoRepeat
 whether the shortcut can auto repeat
 
Qt::ShortcutContext context
 the context in which the shortcut is valid
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

The QShortcut class is used to create keyboard shortcuts.

\inmodule QtGui

The QShortcut class provides a way of connecting keyboard shortcuts to Qt's \l{signals and slots} mechanism, so that objects can be informed when a shortcut is executed. The shortcut can be set up to contain all the key presses necessary to describe a keyboard shortcut, including the states of modifier keys such as \uicontrol Shift, \uicontrol Ctrl, and \uicontrol Alt.

\target mnemonic

In widget applications, certain widgets can use '&' in front of a character. This will automatically create a mnemonic (a shortcut) for that character, e.g. "E&xit" will create the shortcut \uicontrol Alt+X (use '&&' to display an actual ampersand). The widget might consume and perform an action on a given shortcut. On X11 the ampersand will not be shown and the character will be underlined. On Windows, shortcuts are normally not displayed until the user presses the \uicontrol Alt key, but this is a setting the user can change. On Mac, shortcuts are disabled by default. Call \l qt_set_sequence_auto_mnemonic() to enable them. However, because mnemonic shortcuts do not fit in with Aqua's guidelines, Qt will not show the shortcut character underlined.

For applications that use menus, it may be more convenient to use the convenience functions provided in the QMenu class to assign keyboard shortcuts to menu items as they are created. Alternatively, shortcuts may be associated with other types of actions in the QAction class.

The simplest way to create a shortcut for a particular widget is to construct the shortcut with a key sequence. For example:

shortcut = new QShortcut(QKeySequence(tr("Ctrl+O", "File|Open")),
parent);

When the user types the \l{QKeySequence}{key sequence} for a given shortcut, the shortcut's activated() signal is emitted. (In the case of ambiguity, the activatedAmbiguously() signal is emitted.) A shortcut is "listened for" by Qt's event loop when the shortcut's parent widget is receiving events.

A shortcut's key sequence can be set with setKey() and retrieved with key(). A shortcut can be enabled or disabled with setEnabled(), and can have "What's This?" help text set with setWhatsThis().

See also
QShortcutEvent, QKeySequence, QAction

Definition at line 18 of file qshortcut.h.

Constructor & Destructor Documentation

◆ QShortcut() [1/11]

QShortcut::QShortcut ( QObject * parent)
explicit

Constructs a QShortcut object for the parent, which should be a QWindow or a QWidget.

Since no shortcut key sequence is specified, the shortcut will not emit any signals.

See also
setKey()

Definition at line 163 of file qshortcut.cpp.

◆ QShortcut() [2/11]

QShortcut::QShortcut ( const QKeySequence & key,
QObject * parent,
const char * member = nullptr,
const char * ambiguousMember = nullptr,
Qt::ShortcutContext context = Qt::WindowShortcut )
explicit

Constructs a QShortcut object for the parent, which should be a QWindow or a QWidget.

The shortcut operates on its parent, listening for \l{QShortcutEvent}s that match the key sequence. Depending on the ambiguity of the event, the shortcut will call the member function, or the ambiguousMember function, if the key press was in the shortcut's context.

Definition at line 178 of file qshortcut.cpp.

◆ QShortcut() [3/11]

QShortcut::QShortcut ( QKeySequence::StandardKey standardKey,
QObject * parent,
const char * member = nullptr,
const char * ambiguousMember = nullptr,
Qt::ShortcutContext context = Qt::WindowShortcut )
explicit
Since
6.0 Constructs a QShortcut object for the parent, which should be a QWindow or a QWidget.

The shortcut operates on its parent, listening for \l{QShortcutEvent}s that match the standardKey. Depending on the ambiguity of the event, the shortcut will call the member function, or the ambiguousMember function, if the key press was in the shortcut's context.

Definition at line 205 of file qshortcut.cpp.

◆ QShortcut() [4/11]

template<typename Func1 >
QShortcut::QShortcut ( const QKeySequence & key,
QObject * parent,
Func1 slot1,
Qt::ShortcutContext context = Qt::WindowShortcut )
inline

Definition at line 75 of file qshortcut.h.

◆ QShortcut() [5/11]

template<class Obj1 , typename Func1 >
QShortcut::QShortcut ( const QKeySequence & key,
QObject * parent,
const Obj1 * object1,
Func1 slot1,
Qt::ShortcutContext context = Qt::WindowShortcut,
typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type * = 0 )
inline

Definition at line 83 of file qshortcut.h.

◆ QShortcut() [6/11]

template<class Obj1 , typename Func1 , typename Func2 >
QShortcut::QShortcut ( const QKeySequence & key,
QObject * parent,
const Obj1 * object1,
Func1 slot1,
Func2 slot2,
Qt::ShortcutContext context = Qt::WindowShortcut,
typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type * = 0 )
inline

Definition at line 92 of file qshortcut.h.

◆ QShortcut() [7/11]

template<class Obj1 , typename Func1 , class Obj2 , typename Func2 >
QShortcut::QShortcut ( const QKeySequence & key,
QObject * parent,
const Obj1 * object1,
Func1 slot1,
const Obj2 * object2,
Func2 slot2,
Qt::ShortcutContext context = Qt::WindowShortcut,
typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type * = 0,
typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj2 * >::Value >::type * = 0 )
inline

Definition at line 102 of file qshortcut.h.

◆ QShortcut() [8/11]

template<typename Func1 >
QShortcut::QShortcut ( QKeySequence::StandardKey key,
QObject * parent,
Func1 slot1,
Qt::ShortcutContext context = Qt::WindowShortcut )
inline

Definition at line 115 of file qshortcut.h.

◆ QShortcut() [9/11]

template<class Obj1 , typename Func1 >
QShortcut::QShortcut ( QKeySequence::StandardKey key,
QObject * parent,
const Obj1 * object1,
Func1 slot1,
Qt::ShortcutContext context = Qt::WindowShortcut,
typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type * = 0 )
inline

Definition at line 123 of file qshortcut.h.

◆ QShortcut() [10/11]

template<class Obj1 , typename Func1 , typename Func2 >
QShortcut::QShortcut ( QKeySequence::StandardKey key,
QObject * parent,
const Obj1 * object1,
Func1 slot1,
Func2 slot2,
Qt::ShortcutContext context = Qt::WindowShortcut,
typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type * = 0 )
inline

Definition at line 132 of file qshortcut.h.

◆ QShortcut() [11/11]

template<class Obj1 , typename Func1 , class Obj2 , typename Func2 >
QShortcut::QShortcut ( QKeySequence::StandardKey key,
QObject * parent,
const Obj1 * object1,
Func1 slot1,
const Obj2 * object2,
Func2 slot2,
Qt::ShortcutContext context = Qt::WindowShortcut,
typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj1 * >::Value >::type * = 0,
typename std::enable_if< QtPrivate::IsPointerToTypeDerivedFromQObject< Obj2 * >::Value >::type * = 0 )
inline

Definition at line 142 of file qshortcut.h.

◆ ~QShortcut()

QShortcut::~QShortcut ( )

Destroys the shortcut.

Definition at line 336 of file qshortcut.cpp.

Member Function Documentation

◆ activated

void QShortcut::activated ( )
signal

This signal is emitted when the user types the shortcut's key sequence.

See also
activatedAmbiguously()

◆ activatedAmbiguously

void QShortcut::activatedAmbiguously ( )
signal

When a key sequence is being typed at the keyboard, it is said to be ambiguous as long as it matches the start of more than one shortcut.

When a shortcut's key sequence is completed, activatedAmbiguously() is emitted if the key sequence is still ambiguous (i.e., it is the start of one or more other shortcuts). The activated() signal is not emitted in this case.

See also
activated()

◆ autoRepeat()

bool QShortcut::autoRepeat ( ) const

Definition at line 495 of file qshortcut.cpp.

◆ context()

Qt::ShortcutContext QShortcut::context ( ) const

Definition at line 469 of file qshortcut.cpp.

Referenced by testing.tools.safetynet_job.JobRun::_BuildRunMetadata(), testing.tools.safetynet_job.JobRun::_IncrementalRun(), testing.tools.safetynet_job.JobRun::_WriteCheckpoint(), testing.tools.safetynet_job.JobRun::_WriteRawJson(), and testing.tools.safetynet_job.JobRun::Run().

+ Here is the caller graph for this function:

◆ event()

bool QShortcut::event ( QEvent * e)
overrideprotectedvirtual

Reimplemented from QObject.

Definition at line 561 of file qshortcut.cpp.

◆ isEnabled()

bool QShortcut::isEnabled ( ) const

Definition at line 441 of file qshortcut.cpp.

◆ key()

QKeySequence QShortcut::key ( ) const

Definition at line 364 of file qshortcut.cpp.

◆ keys()

QList< QKeySequence > QShortcut::keys ( ) const

Returns the list of key sequences which trigger this shortcut.

Since
6.0
See also
key, setKeys()

Definition at line 409 of file qshortcut.cpp.

◆ setAutoRepeat()

void QShortcut::setAutoRepeat ( bool on)

Definition at line 484 of file qshortcut.cpp.

◆ setContext()

void QShortcut::setContext ( Qt::ShortcutContext context)

Definition at line 459 of file qshortcut.cpp.

◆ setEnabled()

void QShortcut::setEnabled ( bool enable)

Definition at line 430 of file qshortcut.cpp.

◆ setKey()

void QShortcut::setKey ( const QKeySequence & key)

Definition at line 356 of file qshortcut.cpp.

◆ setKeys() [1/2]

void QShortcut::setKeys ( const QList< QKeySequence > & keys)

Sets keys as the list of key sequences that trigger the shortcut.

Since
6.0
See also
key, keys()

Definition at line 380 of file qshortcut.cpp.

◆ setKeys() [2/2]

void QShortcut::setKeys ( QKeySequence::StandardKey key)

Sets the triggers to those matching the standard key key.

Since
6.0
See also
key, keys()

Definition at line 397 of file qshortcut.cpp.

◆ setWhatsThis()

void QShortcut::setWhatsThis ( const QString & text)

Sets the shortcut's "What's This?" help text.

The text will be shown when a widget application is in "What's This?" mode and the user types the shortcut key() sequence.

To set "What's This?" help on a menu item (with or without a shortcut key), set the help on the item's action.

By default, the help text is an empty string.

This function has no effect in applications that don't use widgets.

See also
QWhatsThis::inWhatsThisMode(), QAction::setWhatsThis()

Definition at line 518 of file qshortcut.cpp.

◆ whatsThis()

QString QShortcut::whatsThis ( ) const

Returns the shortcut's "What's This?" help text.

See also
setWhatsThis()

Definition at line 529 of file qshortcut.cpp.

Property Documentation

◆ autoRepeat

bool QShortcut::autoRepeat
readwrite

whether the shortcut can auto repeat

If true, the shortcut will auto repeat when the keyboard shortcut combination is held down, provided that keyboard auto repeat is enabled on the system. The default value is true.

Definition at line 24 of file qshortcut.h.

◆ context

Qt::ShortcutContext QShortcut::context
readwrite

the context in which the shortcut is valid

A shortcut's context decides in which circumstances a shortcut is allowed to be triggered. The normal context is Qt::WindowShortcut, which allows the shortcut to trigger if the parent (the widget containing the shortcut) is a subwidget of the active top-level window.

By default, this property is set to Qt::WindowShortcut.

Definition at line 25 of file qshortcut.h.

Referenced by testing.tools.safetynet_job.JobRun::_BuildRunMetadata(), testing.tools.safetynet_job.JobRun::_IncrementalRun(), testing.tools.safetynet_job.JobRun::_WriteCheckpoint(), testing.tools.safetynet_job.JobRun::_WriteRawJson(), and testing.tools.safetynet_job.JobRun::Run().

◆ enabled

bool QShortcut::enabled
readwrite

whether the shortcut is enabled

An enabled shortcut emits the activated() or activatedAmbiguously() signal when a QShortcutEvent occurs that matches the shortcut's key() sequence.

If the application is in WhatsThis mode the shortcut will not emit the signals, but will show the "What's This?" text instead.

By default, this property is true.

See also
whatsThis

Definition at line 23 of file qshortcut.h.

◆ key

QKeySequence QShortcut::key
readwrite

the shortcut's primary key sequence

This is a key sequence with an optional combination of Shift, Ctrl, and Alt. The key sequence may be supplied in a number of ways:

setKey(0); // no signal emitted
setKey(QKeySequence()); // no signal emitted
setKey(0x3b1); // Greek letter alpha
setKey(Qt::Key_D); // 'd', e.g. to delete
setKey('q'); // 'q', e.g. to quit
setKey(Qt::CTRL | Qt::Key_P); // Ctrl+P, e.g. to print document
setKey("Ctrl+P"); // Ctrl+P, e.g. to print document
The QShortcut class is used to create keyboard shortcuts.
Definition qshortcut.h:19
@ CTRL
@ Key_D
Definition qnamespace.h:554
@ Key_P
Definition qnamespace.h:566
setKey(0)
[0]

By default, this property contains an empty key sequence.

Definition at line 22 of file qshortcut.h.


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