Handle keyboard in QML

This commit is contained in:
2020-06-23 16:29:36 -06:00
parent af761ca337
commit 82ff240cfd
5 changed files with 80 additions and 33 deletions

View File

@@ -4,11 +4,22 @@ import QtQuick.Layouts 1.3
import Magnum 1.0
ApplicationWindow {
id: app
visible: true
width: 640
height: 480
title: qsTr("My Application")
Shortcut {
sequence: "q"
onActivated: app.close()
}
Shortcut {
sequence: "l"
onActivated: lagging.checked = !lagging.checked
}
RowLayout {
id: root
anchors.fill: parent
@@ -81,11 +92,19 @@ ApplicationWindow {
Layout.preferredWidth: parent.width
CheckBox {
text: "Lagging"
id: lagging
text: "Lagging (L)"
onCheckStateChanged: {
if (checked)
magnum.lagging = 0.85
else
magnum.lagging = 0
}
}
}
}
Magnum {
id: magnum
Layout.fillHeight: true
Layout.fillWidth: true