Shortcut QML Type
Provides keyboard shortcuts 更多...
Import Statement: | import QtQuick 2.7 |
开始支持版本: | Qt 5.5 |
属性
- autoRepeat : bool
- context : enumeration
- enabled : bool
- nativeText : string
- portableText : string
- sequence : keysequence
- sequences : list<keysequence>
信号
详细描述
The Shortcut type provides a way of handling keyboard shortcuts. The shortcut can be set to one of the standard keyboard shortcuts, or it can be described with a string containing a sequence of up to four key presses that are needed to activate the shortcut.
Item { id: view property int currentIndex Shortcut { sequence: StandardKey.NextChild onActivated: view.currentIndex++ } }
It is also possible to set multiple shortcut sequences, so that the shortcut can be activated via several different sequences of key presses.
参见 Keys and shortcutOverride().
属性
This property holds whether the shortcut can auto repeat.
The default value is true
.
This property holds the shortcut context.
Supported values are:
Qt.WindowShortcut
(default) - The shortcut is active when its parent item is in an active top-level window.Qt.ApplicationShortcut
- The shortcut is active when one of the application's windows are active.
Shortcut { sequence: StandardKey.Quit context: Qt.ApplicationShortcut onActivated: Qt.quit() }
This property provides the shortcut's key sequence as a platform specific string. This means that it will be shown translated, and on macOS it will resemble a key sequence from the menu bar. It is best to display this text to the user (for example, on a tooltip).
This QML property was introduced in Qt 5.6.
参见 sequence and portableText.
This property provides the shortcut's key sequence as a string 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.
This QML property was introduced in Qt 5.6.
参见 sequence and nativeText.
This property holds the shortcut's key sequence. The key sequence can be set to one of the standard keyboard shortcuts, or it can be described with a string containing a sequence of up to four key presses that are needed to activate the shortcut.
The default value is an empty key sequence.
Shortcut { sequence: "Ctrl+E,Ctrl+W" onActivated: edit.wrapMode = TextEdit.Wrap }
参见 sequences.
This property holds multiple key sequences for the shortcut. The key sequences can be set to one of the standard keyboard shortcuts, or they can be described with strings containing sequences of up to four key presses that are needed to activate the shortcut.
Shortcut { sequences: [StandardKey.Cut, "Ctrl+X", "Shift+Del"] onActivated: edit.cut() }
This QML property was introduced in Qt 5.9.
信号
This signal is emitted when the shortcut is activated.
The corresponding handler is onActivated
.
This signal is emitted when the shortcut is activated ambigously, meaning that it matches the start of more than one shortcut.
The corresponding handler is onActivatedAmbiguously
.