[SOLVED] ScrollView scrollbars visibility issue



  • Hello everyone,

    I am currently playing with ScrollViews containing a ListView instance. In my understanding, scrollbars should be visible everytime the width/height of ListView contentItem exceed the ScrollView one.

    So I test these two cases. The first, with a simple Rectangle, bigger than its ScrollView container:

    @import QtQuick 2.3
    import QtQuick.Controls 1.2

    Item {
    width: 600
    height: 600

    ScrollView {
    anchors.fill: parent

    Rectangle {
    width: 800
    height: 800
    color: "red"
    }
    }
    }

    @

    which behave as expected. The second one use a ListView instead of a dummy Rectangle:

    @import QtQuick 2.3
    import QtQuick.Controls 1.2

    Item {
    width: 300
    height: 400

    ScrollView {
    anchors.fill: parent

    ListView{
    id: listView
    width: 500
    height: 400

    model: 20
    delegate: Row {
    Rectangle {
    height: 250
    width: 200
    color: index % 2 == 0 ? "red" : "blue"
    }
    Rectangle {
    height: 250
    width: 200
    color: index % 2 == 1 ? "red" : "blue"
    }
    }
    }
    }
    }
    @

    Here come my issue, or something I don't understand. In this case, why the vertical scrollbar appears and not the horizontal one? Thanks in advance for some enlighentment.


  • Moderators

    Hi,

    As far as I understand the flickableitem for the scrollview here is the ListView, so content size of the ScrollView will the same as that of the ListView which is not defined in above example. Try setting contentWidth to ListView and it should work. May be there's better explanation than this.
    More info "here":http://qt-project.org/doc/qt-5/qml-qtquick-controls-scrollview.html



  • Thanks for your reply! Setting contentWidth fixed effectively my problem. Nevertheless, I thought naively that a ListView would adapt its contentWidth/contentHeight accordingly with the space taken by its children.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.