
- 小巧思,小技巧
- 通过一个hoverEnabled的 RoundButton来实现苹果小圆球的拖拽
- 通过对hovered 的判断实现透明度的设计
- 通过RoundButton的来实现核心SwipeView的切换
RoundButton {//仿苹果的小按钮,实现不同功能
id: backBtn
z: 109
x: parent.x + parent.width - 90
y: parent.y + parent.height / 2 - 50
width: 60
height: 60
focus: false
visible: mainSwipeView.currentIndex != 0
hoverEnabled: enabled
opacity: hovered ? 1 : 0.5
background: Rectangle{
color: "#55ffffff"
radius: parent.width / 2
}
Image {
anchors.centerIn: parent
id: backImage
source: "qrc:/desktop/images/back.png"
}
MouseArea {
//这段代码的主要用途是实现一个可拖动的返回按钮,当用户在浏览页面时,可以方便地返回上一个页面
anchors.fill: parent
drag.target: backBtn
drag.minimumX: 0
drag.minimumY: 0
drag.maximumX: mainWindow.width - 60
drag.maximumY: mainWindow.height - 60
onClicked: {
mainSwipeView.currentIndex = 0
}
}
}