qml 键盘事件传递的顺序
-
思考:键盘事件传递的顺序是什么样子的 ?
编写以下代码作为测试:
import QtQuick 2.7 import QtQuick.Window 2.2 Rectangle{ width: 800; height: 800; Rectangle{ id: rect_a; anchors.top: parent.top; anchors.left: parent.left; width: 400; height: 400; color: focus ? "#111111" : "#db1f5b"; focus: true; Keys.onPressed: { if(event.key === Qt.Key_A){ console.log("A pressed"); event.accepted = true; }