을 방지하는 방법에 바인딩하는 경우 루프 설정 패딩?

0

질문

나 업데이트하고 싶은 패딩의 스크롤이 있는 경우 스크롤 막대가 표시되지만,다른 한편으로의 가시성 스크롤 막대가에 의존하는 고도/폭의 콘텐츠 안에 스크롤바를 변경하는 경우 패딩을 변경합니다. 다음과 같은 이유가 있습니다 바인딩 loop:

ScrollView {
  id: control
  rightPadding: Scrollbar.vertical.visible ? Scrollbar.vertical.width : 0
   ....


  ScrollBar.vertical: ScrollBar {
    parent: control
    visible: control.height < height
   ...
  }
}

내가 어떻게 이것을 달성할 수 없는 바인딩니까? 감사

qml qt qtquickcontrols2
2021-11-15 14:43:32
1

최고의 응답

0

할 수있는 코드 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 는 랩이 충분하지 않을 경우 폭,하게 되는 그것이 원인이 되는 키가 큰 경우는 폭이 감소한다. 이것은 다시 얻으로 무한 루프 지역이다.

2021-11-16 04:25:42

귀하의 의견에 감사드립니다. 는지 정확히 무엇인가에 대한 내용 textArea 는 단어와 랩을,어디서 높이가에 의존하는 폭입니다. 이 있을 수 있는 방법을 피 재귀 이 경우에는?
Denis

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................