可能可以,這是一個錯誤,但請往下看:在下面的代碼組合的Flipable和鼠標區域腳麻在QML
,在flipable前面的鼠標區域保持活躍時flipable翻轉(但相反的),甚至接管一些鼠標區域從背面:
import QtQuick 2.0
Rectangle {
height: 500
width: 500
Flipable {
id: flipable
anchors.fill:parent
property bool flipped: false
front: Rectangle{
color: "black"
anchors.fill: parent
Rectangle {
color:"darkgrey"
height: parent.height/2
width: parent.width/2
MouseArea {
anchors.fill: parent
onClicked: flipable.flip()
}
}
}
back: Rectangle {
id: yellow
color: "yellow"
anchors.fill: parent
MouseArea {
anchors.fill: parent
onClicked: yellow.color = "green"
}
}
transform: Rotation {
id: rotation
origin.x: flipable.width/2
origin.y: flipable.height/2
axis.x: 0; axis.y: 1; axis.z: 0 // set axis.y to 1 to rotate around y-axis
angle: 0 // the default angle
}
states: State {
name: "back"
PropertyChanges { target: rotation; angle: 180 }
when: flipable.flipped
}
transitions: Transition {
NumberAnimation { target: rotation; property: "angle"; duration: 400 }
}
function flip() {
flipped = !flipped
}
}
}
當你按下灰色區域的頁面翻轉,如果再次按下它(現在是右邊後面)再次翻轉。正確的行爲是黃色方塊變成綠色,即使點擊右上角。
謝謝!
您應該添加一個明確的問題的...問題。 – hyde