我嘗試用切換功能切換我的導航。我想改變「x」的位置。QML切換PropertyChanges onclick
所以這裏是我到目前爲止。但不行。我嘗試使用切換功能來點擊點擊狀態。我設置了兩個不同的狀態,一個是導航可見,另一個是隱藏導航。
我得到這個錯誤 「的ReferenceError:切換沒有定義」
Item {
id: toggleswitch
width: 200
height: 200
property bool on: false
function toggle() {
if (toggleswitch.state == "on")
toggleswitch.state = "off";
else
toggleswitch.state = "on";
}
Rectangle {
id: open
width: parent.width
height: 35
color: "#33000000"
Text {
anchors.centerIn: parent
text: "open"
color: "white"
font.family: "Helvetica"
font.pixelSize: 25
}
MouseArea { anchors.fill: parent; onClicked: toggle() }
}
states: [
State {
name: "on"
PropertyChanges { target: navigation; x: 0 }
PropertyChanges { target: toggleswitch; on: true }
},
State {
name: "off"
PropertyChanges { target: navigation; x: -300 }
PropertyChanges { target: toggleswitch; on: false }
}
]
}
什麼'這裏navigation'? – folibis 2014-10-19 21:53:44
導航是一個矩形。我想製作像這樣的http://api.jquery.com/slidetoggle/。矩形滑入和滑出。 – Matthias 2014-10-20 08:44:50