ApplicationWindow{
visible: true
height:
300
width:
530
ScrollView{
id:scroll
width:
530
height:
300
Rectangle{
id: rect
width:
500
height:
900
Rectangle{
id:rect1
anchors
.top: rect
.top
width:
500
height:
300
color:
"red"
border
.color:
"blue"
}
Rectangle{
id: rect2
anchors
.top: rect1
.bottom
width:
500
height:
300
color:
"green"
border
.color:
"blue"
}
Rectangle{
id: rect3
anchors
.top: rect2
.bottom
width:
500
height:
900
color:
"orange"
border
.color:
"blue"
MouseArea{
anchors
.fill: parent
onClicked: {
scroll
.flickableItem.contentY = rect2
.y
}
}
}
}
}
}
图片预览如下
再点击第三个矩形块的时候,会自动将滚动条置于第2个矩形。