2.1 KiB
| sidebar_label | title |
|---|---|
| QShortcut | QShortcut |
The QShortcut class is used to create keyboard shortcuts.
This class is a JS wrapper around Qt's QShortcut class
QShortcut inherits from EventWidget
Example
const { QShortcut, QKeySequence, QMainWindow } = require("@nodegui/nodegui");
const win = new QMainWindow();
const shortcut = new QShortcut(win);
shortcut.setKey(new QKeySequence("Ctrl+M"));
shortcut.setEnabled(true);
shortcut.addEventListener(QShortcutEvents.activated, () => {
console.log("Shortcut Activated");
});
win.show();
global.win = win;
global.shortcut = shortcut;
new QShortcut(parent)
parentNodeWidget. Any widget inheriting from NodeWidget can be passed as a parent. This will make this shortcut bind to the parent widget.
Static Methods
QShortcut can access all the static methods defined in EventWidget
Instance Properties
QShortcut can access all the instance properties defined in EventWidget
Instance Methods
QShortcut can access all the instance methods defined in EventWidget. Additionally it also has the following instance methods:
shortcut.setEnabled(enabled)
This property holds whether the shortcut is enabled. It calls the native method QShortcut: setEnabled.
enabled- Boolean
shortcut.setAutoRepeat(on)
This property holds whether the shortcut can auto repeat. It calls the native method QShortcut: setAutoRepeat.
on- Boolean
shortcut.setKey(keySequence)
This property holds the shortcut's key sequence. It calls the native method QShortcut: setKey.
keySequenceQKeySequence
shortcut.setContext(contextEnum)
This property holds the context in which the shortcut is valid. It calls the native method QShortcut: setContext.
contextEnum- ShortcutContext enum.