我尝试用切换功能切换我的导航。我想改变“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