Handling ApplicationWindow QML2 Manipulations
Is there a way to handle keypress events in the ApplicationWindow of the component QtQuick.Controls
? The Qt5.3 documentation does not provide any way to do this. Also, it says that Keys
it only exists in Item
-objects. When I try to handle the keypress event, it says " Failed to bind Keys property to: ApplicationWindow_QMLTYPE_16 (0x31ab890) is not an element ":
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.1
import QtQuick.Window 2.1
ApplicationWindow {
id: mainWindow
visible: true
width: 720
height: 405
flags: Qt.FramelessWindowHint
title: qsTr("test")
x: (Screen.width - width) / 2
y: (Screen.height - height) / 2
TextField {
id: textField
x: 0
y: 0
width: 277
height: 27
placeholderText: qsTr("test...")
}
Keys.onEscapePressed: {
mainWindow.close()
event.accepted = true;
}
}
+3
source to share