Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] ScrollView scrollbars visibility issue
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] ScrollView scrollbars visibility issue

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jb2a
    wrote on 30 Oct 2014, 23:28 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 31 Oct 2014, 05:12 last edited by
      #2

      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

      157

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jb2a
        wrote on 31 Oct 2014, 10:46 last edited by
        #3

        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.

        1 Reply Last reply
        0

        1/3

        30 Oct 2014, 23:28

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved