Details
-
Bug
-
Resolution: Unresolved
-
P4: Low
-
None
-
5.0.0 Beta 2
-
None
-
Ubuntu 12.04 Qt5 Beta 1
-
e03e870b7b4aac85e85b56655ccbc5d99c91053f
Description
If a item has the Key.onPressed implemented and then is overridden by PropertyChanges in a State, the Key.onPressed will fail on event variable with the following message:
main.qml:88: ReferenceError: event is not defined
The code works in Qt 4.8 and I think it worked in Qt5 Alpha.
See the following example:
import QtQuick 2.0 Rectangle { id: mainRectangle width: 400 height: 400 Text { id: keyResultText anchors.top: parent anchors.horizontalCenter: parent.horizontalCenter } Rectangle { id: topRectangle anchors.centerIn: parent color: "lightgreen" width: 200 height: 150 Text { id: textId text: "Default State (Click to change)" anchors.centerIn: parent } MouseArea { id: stateChangeMouseArea anchors.fill: parent onClicked: { mainRectangle.state = "Awesome State 3000" } } } Rectangle { id: keyRectangle border.width: 1 width: 200 height: 100 anchors.top: topRectangle.bottom anchors.horizontalCenter: topRectangle.horizontalCenter anchors.topMargin: 15 focus: true Text { id: textId2 text: "Press Enter" } Keys.onPressed: { if(event.key === Qt.Key_Return) { keyResultText.text = "Enter Pressed!" } } } states: [ State { name: "Awesome State 3000" PropertyChanges { target: textId text: "Awesome State 3000 (Click to change)" } PropertyChanges { target: textId2 text: "Press Space (This will error!)" } PropertyChanges { target: stateChangeMouseArea onClicked: { mainRectangle.state = "" } } PropertyChanges { target: keyRectangle Keys.onPressed: { if(event.key === Qt.Key_Space) { keyResultText.text = "Enter Space!" } } } } ] }
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-27300 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
40211,1 | Deliver parameters to bound signals. | master | qt/qtdeclarative | Status: MERGED | +2 | 0 |