0

I am currently learning QML. I have a ScrollView that is not displaying the vertical scrollbar at all. I have tried this solution but it has not worked. The code (some stuff left out) is part of a larger code base available in this GitHub repository.

EDITS: I have updated the code to create a Minimal, Reproducible Example EDIT 2 Been trying to solve the problem. I found a solution but I don't understand why it works. When I place the ScrollView inside the StackView. The vertical scrollbar appears and works as expected.

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12


Window {
 id: top
  visible: true
  width: 640
  height: 360

  RowLayout {
   spacing: 0
   anchors.fill: parent

 Pane {
id: mainbar
Layout.margins: 0
Layout.fillHeight: true
Layout.fillWidth: true

  ColumnLayout {
    spacing: 1
    anchors.fill: parent

    Rectangle {
      Layout.fillHeight: true
      Layout.fillWidth: true
      ScrollView {
        anchors.fill: parent
        clip: true

          StackView {
            id: stack
            anchors.fill: parent
            initialItem: mainView
           }
Component {
    id: mainView

    Column {
        spacing: 10


        Text {
            text: stack.depth
        }

        Button {
            text: "1"
        }
        Button {
            text: "2"

        }
        Button {
            text: "3"
        }
        Button {
            text: "4"

        }
        Button {
            text: "5"
        }
        Button {
            text: "6"

        }
        Button {
            text: "7"

        }
        Button {
            text: "8"

        }
        Button {
            text: "9"

        }
    }
}

          }
      }
  }
 }
 }
 }
Eric O.
  • 474
  • 4
  • 23
  • Would [`ScrollView`](https://doc.qt.io/qt-5/qml-qtquick-controls2-pane.html) work? It is a child by inheritance of `Pane`. [See also this question](https://stackoverflow.com/questions/42189391/how-to-make-scrollbar-always-visible-on-flckable-in-qml) – Ross Rogers Jun 07 '20 at 17:49
  • Just out of interest, don't you think there are too many nested objects? What a sense in `StackView` inside `ScrollView`? `ScrollView` inside invisible `Rectangle`? `ColumnLayout` that contains only one item? – folibis Jun 08 '20 at 09:50
  • @folibis As said in the question, I have left out some code that I thought is not necessary. The code posted here is part of the code in main.qml. You can check all the code from the GitHub link provided. – Eric O. Jun 08 '20 at 09:57
  • You should provide [mre], not external links, if you really want to solve the problem. Not everyone will want to use third-party sites. – folibis Jun 08 '20 at 12:27
  • I have updated the code. It can be run independently to produce the problem. – Eric O. Jun 08 '20 at 17:05
  • Been trying to solve the problem. I found a solution but I don't understand why it works. When I place the ScrollView inside the StackView. The vertical scrollbar appears and works as expected. – Eric O. Jun 09 '20 at 10:13

0 Answers0