Shortcut QML 类型

提供键盘快捷键。 更多...

import 语句: import QtQuick 2.2
Since: Qt 5.5

特性

信号

详细描述

The Shortcut type provides a way of handling keyboard shortcuts. The shortcut can be set to one of the 标准键盘快捷键 , 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() .

特性文档编制

autoRepeat : bool

This property holds whether the shortcut can auto repeat.

默认值为 true .

context : enumeration

此特性保持 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()
}
					
enabled : bool

This property holds whether the shortcut is enabled.

默认值为 true .

[since 5.6] nativeText : string

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).

该特性在 Qt 5.6 引入。

另请参阅 sequence and portableText .

[since 5.6] portableText : string

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.

该特性在 Qt 5.6 引入。

另请参阅 sequence and nativeText .

sequence : keysequence

This property holds the shortcut's key sequence. The key sequence can be set to one of the 标准键盘快捷键 , 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 .

[since 5.9] sequences : list < keysequence >

This property holds multiple key sequences for the shortcut. The key sequences can be set to one of the 标准键盘快捷键 , 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()
}
					

该特性在 Qt 5.9 引入。


信号文档编制

activated ()

This signal is emitted when the shortcut is activated.

注意: 相应处理程序是 onActivated .

activatedAmbiguously ()

This signal is emitted when the shortcut is activated ambigously, meaning that it matches the start of more than one shortcut.

注意: 相应处理程序是 onActivatedAmbiguously .