Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-69376

ScrollView will not scroll for particular content items

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.9.2, 5.10.1
    • None
    • macOS, Windows
    • 5783cc354b85ba9a77378da34d911a0cfdb31b73

       

      Since QtQuick Controls 2, Scrollview does not let you scroll if you simply put a rectangle inside:

      import QtQuick.Controls 2.2
      
      //...
      
          ScrollView {
              id : scrollview
              anchors.fill: parent
              clip: true
      
              Rectangle {
                  width : scrollview.width
                  height: 400
                  gradient: Gradient {
                      GradientStop { position: 0.0; color: "red" }
                      GradientStop { position: 0.33; color: "yellow" }
                      GradientStop { position: 1.0; color: "green" }
                  }
              }
          }
      

      Which is a simple variant of the example in the documentation (where a Label is used instead of the Rectangle): https://doc.qt.io/qt-5.11/qml-qtquick-controls2-scrollview.html .

      A workaround is to anchors the Rectangle inside a Layout, e.g.

      ScrollView {
              id : scrollview
              anchors.fill: parent
              clip: true
      
              ColumnLayout {
                  width : scrollview.width
                  height: 400
                  spacing: 0
      
                  Rectangle {
                      anchors.fill : parent
                      gradient: Gradient {
                          GradientStop { position: 0.0; color: "red" }
                          GradientStop { position: 0.33; color: "yellow" }
                          GradientStop { position: 1.0; color: "green" }
                      }
                  }
              }
          }
      

      Unless i missed it, this limitation is not mentioned anywhere.

      ScrollView works as expected with QtQuick Controls 1.

       

        For Gerrit Dashboard: QTBUG-69376
        # Subject Branch Project Status CR V

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            simonconan Simon Conan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes