主要是用來判斷鼠標事件的區域
Rectangle{
x: 0; y: 0;
width: 100; height:100;
Rectangle{
id: mousrect
x: 20; y: 20;
width: 20; height: 20;
color: “blue”
MouseArea{
// 使用父的區域作為鼠標判斷的區域及 x: 20; y: 20; width: 20; height: 20;
anchors.fill: parent;
// 但鼠標按下后 mousrect變成紅色,當鼠標松開后變成藍色
onPRessed: { mousrect.color =”red”;}
onReleased: { mousrect.color =”blue”;}
}
}
}
FocusScope不是很清楚說的什么,好像是說同一個時刻只有一個item有焦點
Flickable顯示一個200x200的框,框中顯示圖片上200x200的部分
Flickable {
width: 200; height: 200
// 設置使用圖片的寬高,而現實的是 200x200的現實框
contentWidth: image.width; contentHeight:image.height
Image { id: image; source:”../Images/need.png” }
}
Flipable包含兩個面,一個前面,一個后面,實現一個控件前后的翻轉效果,并且在后面可以添加一些控制
Flipable {
id: flipable
width: 240
height: 240
property int angle: 0
property bool flipped: false
front: Image {source: “front.png” } // 前面
back: Image { source: “back.png”} // 后面
// 旋轉動畫前后面交換
transform: Rotation {
origin.x: flipable.width/2; origin.y:flipable.height/2
axis.x: 0; axis.y: 1; axis.z: 0 // rotatearound y-axis
angle: flipable.angle
}
states: State {
name: “back”
PropertyChanges { target: flipable; angle:180 }
when: flipable.flipped
}
transitions: Transition {
NumberAnimation { properties:”angle”; duration: 1000 }
}
MouseArea {
anchors.fill: parent
onClicked: flipable.flipped =!flipable.flipped
}
}
State// 當鼠標按下后改變 myRect 的顏色
Rectangle {
id: myRect
width: 100; height: 100
color: “black”
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: myRect.state == ‘clicked’ ?myRect.state = “” : myRect.state = ‘clicked’;
}
// 設置狀態
states: [
State {
name: “clicked”
PropertyChanges { target: myRect; color:”red” }
}
]
}
新聞熱點
疑難解答