QML程序中 快捷键的操作,常用于 toolbutton 和 menu 。
shortcut : keysequence
键盘序列使用 系统自带(StanderdKey)或者自定义
有点像键盘Key事件。
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.5
Window {
id:root
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Label{
id:aa
anchors.centerIn: parent
text:"11111111111"
Action {
id:copyAction2
//sequence: "Ctrl+E,Ctrl+W"
shortcut: StandardKey.Copy//"Ctrl+E,Ctrl+W"
onTriggered: {
aa.text = "2222"
console.log("11")
}
}
}
Action {
id: copyAction
text: qsTr("&Copy")
icon.name: "edit-copy"
shortcut: "Ctrl+F"//StandardKey.Copy//StandardKey.Copy
onTriggered: console.log("hello")//root.activeFocusItem.copy()
}
MenuItem {
id: menuItem
action: copyAction
text: qsTr("&Copy selected Text")
}
}