할 수있는 코드 frag 작동하는 것 같은 코드에 의존해야한의 내용 ScrollView
지만,이에 포함되지 않은 코드 frag,그리고 누락 될 수 있습니다 몇 가지 다른 참조가 있습니다.
어쨌든,나는 접근이-다르게 변경 ScrollView
's 콘텐츠의 폭을 기반으로는지 여부 ScrollBar
을 볼 수 있습니다. 또한 설정 ScrollBar
책에 대한 가시성. 아이들 전체를 들어할 수 있는 내용을 추가하거나 삭제하 슬라이더를 사용하는 데모:
import QtQuick 2.15
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
ApplicationWindow {
id: root
visible: true
height: 500
width: 500
ColumnLayout {
anchors {
fill: parent
}
Slider {
// use slider to add delegates to the ScrollView to toggle the scroll bar visibility
id: slider
to: 20
}
ScrollView {
id: scroll
Layout.fillHeight: true
Layout.fillWidth: true
ScrollBar.vertical.policy: scrollBarVisible ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
property bool scrollBarVisible: scroll.contentHeight > scroll.height
ColumnLayout {
width: scroll.scrollBarVisible ? scroll.width - scroll.ScrollBar.vertical.width : scroll.width // change the width of the
Repeater {
model: slider.value
delegate: Rectangle {
color: "tomato"
Layout.fillWidth: true
Layout.preferredHeight: 150
}
}
}
}
}
}
또 하나 주목해야 할 것은 여러분의 ScrollView
콘텐츠 수 없는 그것의 높이에 따라 달라질 수 있을 너비하는 경우,예를 들면,콘텐츠 일 Text
는 랩이 충분하지 않을 경우 폭,하게 되는 그것이 원인이 되는 키가 큰 경우는 폭이 감소한다. 이것은 다시 얻으로 무한 루프 지역이다.