![]() |
CopperSpice API
1.8.2
|
The QShortcut class is used to create keyboard shortcuts. More...
Public Signals | |
void | activated () |
void | activatedAmbiguously () |
![]() | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Methods | |
QShortcut (const QKeySequence &key, QWidget *parent, const QString &member=QString (), const QString &ambiguousMember=QString (), Qt::ShortcutContext context=Qt::WindowShortcut) | |
QShortcut (QWidget *parent) | |
~QShortcut () | |
bool | autoRepeat () const |
Qt::ShortcutContext | context () const |
int | id () const |
bool | isEnabled () const |
QKeySequence | key () const |
QWidget * | parentWidget () const |
void | setAutoRepeat (bool on) |
void | setContext (Qt::ShortcutContext context) |
void | setEnabled (bool enable) |
void | setKey (const QKeySequence &key) |
void | setWhatsThis (const QString &text) |
QString | whatsThis () const |
![]() | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Protected Methods | |
bool | event (QEvent *event) override |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Properties | |
autoRepeat | |
context | |
enabled | |
key | |
whatsThis | |
![]() | |
objectName | |
Additional Inherited Members | |
![]() | |
void | deleteLater () |
![]() | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
![]() | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QShortcut class is used to create keyboard shortcuts.
The QShortcut class provides a way of connecting keyboard shortcuts to the CopperSpice 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 Shift, Ctrl, and Alt.
On certain widgets, using '&' in front of a character will automatically create a mnemonic (a shortcut) for that character, e.g. "E&xit" will create the shortcut 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 Alt key, but this is a setting the user can change. On OS X shortcuts are disabled by default. Call qt_set_sequence_auto_mnemonic() to enable them. However, because mnemonic shortcuts do not fit in with Aqua's guidelines, CopperSpice 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.
When the user types the 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 the CopperSpice 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().
|
explicit |
Constructs a QShortcut object for the parent widget. Since no shortcut key sequence is specified, the shortcut will not emit any signals.
QShortcut::QShortcut | ( | const QKeySequence & | key, |
QWidget * | parent, | ||
const QString & | member = QString() , |
||
const QString & | ambiguousMember = QString() , |
||
Qt::ShortcutContext | context = Qt::WindowShortcut |
||
) |
Constructs a QShortcut object for the parent widget. The shortcut operates on its parent, listening for QShortcutEvents 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.
QShortcut::~QShortcut | ( | ) |
Destroys the shortcut.
|
signal |
This signal is emitted when the user types the shortcut's key sequence.
|
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.
bool QShortcut::autoRepeat | ( | ) | const |
Returns the value of the property.
Qt::ShortcutContext QShortcut::context | ( | ) | const |
Returns the value of the property.
|
overrideprotectedvirtual |
Receives events to an object and should return true if the given event was recognized and processed. This method can be overridden to customize the event handling for an object.
Reimplemented from QObject::event()
int QShortcut::id | ( | ) | const |
Returns the shortcut's ID.
bool QShortcut::isEnabled | ( | ) | const |
Returns the value of the property.
QKeySequence QShortcut::key | ( | ) | const |
Returns the value of the property.
|
inline |
Returns the shortcut's parent widget.
void QShortcut::setAutoRepeat | ( | bool | on | ) |
Sets the value of the property to on.
void QShortcut::setContext | ( | Qt::ShortcutContext | context | ) |
Sets the value of the property to context.
void QShortcut::setEnabled | ( | bool | enable | ) |
Sets the value of the property to enable.
void QShortcut::setKey | ( | const QKeySequence & | key | ) |
Sets the value of the property to key.
void QShortcut::setWhatsThis | ( | const QString & | text | ) |
Sets the value of the property to text.
QString QShortcut::whatsThis | ( | ) | const |
Returns the value of the property.
|
This property holds 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.
Properties | Class Methods |
---|---|
read | autoRepeat |
write | setAutoRepeat |
|
This property holds 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.
Properties | Class Methods |
---|---|
read | context |
write | setContext |
|
This property holds 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.
Properties | Class Methods |
---|---|
read | isEnabled |
write | setEnabled |
|
This property holds the shortcut's 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:
By default, this property contains an empty key sequence.
Properties | Class Methods |
---|---|
read | key |
write | setKey |
|
This property holds the shortcut's "What's This?" help text.
The text will be shown when the 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, this property contains an empty string.
Properties | Class Methods |
---|---|
read | whatsThis |
write | setWhatsThis |