QML Key event Qt.key_Minus can't used
Solved
QML and Qt Quick
-
I run some .qml file with qmlscene, but key event Qt.key_Plus has no effect, and when I pressed Qt.key_Minus several times, the GreenSquare became larger, Qt version: 5.6.0, OS: redhat 6/ubuntu.
Codes:
keys.qml:import QtQuick 2.0 DarkSquare { width: 400; height: 200 GreenSquare { id: square x: 8; y: 8 } focus: true Keys.onLeftPressed: square.x -= 8 Keys.onRightPressed: square.x += 8 Keys.onUpPressed: square.y -= 8 Keys.onDownPressed: square.y += 8 Keys.onPressed: { switch (event.key) { case Qt.Key_Plus: square.scale += 0.2 break; case Qt.Key_Minus: square.scale -= 0.2 break; } } }
DarkSquare.qml:
import QtQuick 2.0 Rectangle { width: 48 height: 48 color: "black" border.color: Qt.darker(color) }
GreenSquare.qml:
import QtQuick 2.0 DarkSquare { width: 48 height: 48 color: "green" border.color: Qt.lighter(color) }
What can I do to avoid this bug, or fix this bug?
-
@neng
If you mean that size of rectangle increased after scale become < 0, then Item.scaleA scale of less than 1.0 causes the item to be rendered at a smaller size, and a scale greater than 1.0 renders the item at a larger size. A negative scale causes the item to be mirrored when rendered.