import QtQuick 2.3 import QtQuick.Controls 1.2 ApplicationWindow { id: root height: 400 width: 400 menuBar: MenuBar { Menu { title: "File" MenuItem { text: "Open..." } MenuItem { text: "Save..." } MenuItem { text: "Save As..." } MenuItem { text: "Exit" } } Menu { title: "Edit" MenuItem { text: "Cut" } MenuItem { text: "Copy" } MenuItem { text: "Paste" } } } Item { id: content anchors.fill: parent focus: true property int keyPressed property int modifierPressed property string keyText property bool altKeyPressed: false property bool mouseActive: false property int xPos property int yPos Keys.onPressed: { keyPressed = event.key; modifierPressed = event.modifiers; keyText = event.text; if (event.key === Qt.Key_Alt) { content.altKeyPressed = true; } } Keys.onReleased: { if (event.key === Qt.Key_Alt) { content.altKeyPressed = false; } } Column { Text { text: "Key: " + content.keyPressed + " Modifier: " + content.modifierPressed + " Text: " + content.keyText } Text { text: "Mouse x position: " + content.xPos + " y position: " + content.yPos + " alt key pressed: " + content.altKeyPressed visible: content.mouseActive } } MouseArea { anchors.fill: parent onClicked: { content.focus = true; } onPressed: { content.mouseActive = true; content.xPos = mouse.x; content.yPos = mouse.y; } onPositionChanged: { content.xPos = mouse.x; content.yPos = mouse.y; } onReleased: { content.mouseActive = false; } } } }