Qml Flickable覆盖内容
Qml Flickable overwrite content
我尝试使用 Flickable
在我的应用程序中启用内容滚动。
现在内容可以滚动,但内容隐藏了顶部内容。
代码:
Flickable {
anchors.top: pageMessagesHeader.bottom
anchors.topMargin: 20
boundsBehavior: Flickable.DragOverBounds
contentHeight: contentItem.childrenRect.height
contentWidth: contentItem.childrenRect.width
height: 500
width: 400
ScrollBar.vertical: ScrollBar {}
Rectangle {
color: "white"
height: 1000
width: 400
id: listMessages
}
}
Here你可以找到一句话:
Flickable does not automatically clip its contents. If it is not used as a full-screen item, you should consider setting the clip property to true.
这是解决方案。
只需添加
clip: true
到你的代码,你会很好。
剪辑有一些 perfomance disavantages 会随着应用程序的增长而对其产生很大影响。因此,应该仔细评估它的使用,尤其是在视图场景之外。
我尝试使用 Flickable
在我的应用程序中启用内容滚动。
现在内容可以滚动,但内容隐藏了顶部内容。
代码:
Flickable {
anchors.top: pageMessagesHeader.bottom
anchors.topMargin: 20
boundsBehavior: Flickable.DragOverBounds
contentHeight: contentItem.childrenRect.height
contentWidth: contentItem.childrenRect.width
height: 500
width: 400
ScrollBar.vertical: ScrollBar {}
Rectangle {
color: "white"
height: 1000
width: 400
id: listMessages
}
}
Here你可以找到一句话:
Flickable does not automatically clip its contents. If it is not used as a full-screen item, you should consider setting the clip property to true.
这是解决方案。
只需添加
clip: true
到你的代码,你会很好。
剪辑有一些 perfomance disavantages 会随着应用程序的增长而对其产生很大影响。因此,应该仔细评估它的使用,尤其是在视图场景之外。