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. ScrollView inside multiple columns
Forum Updated to NodeBB v4.3 + New Features

ScrollView inside multiple columns

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 897 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.
  • P Offline
    P Offline
    PetrM
    wrote on last edited by PetrM
    #1

    Hello all,
    I have a problem with scrolling two columns of images separately.

    This code works as I expect (single column of images):

    import QtQuick 2.9
    import QtQuick.Controls 2.2
    import QtQuick.Layouts 1.3
    
    ApplicationWindow {
        visible: true
        width: 800
        height: 600
    
        Item
        {
            anchors.fill: parent
            ScrollView
            {
                anchors.fill: parent
                ColumnLayout
                {
                    anchors.fill: parent
                    Repeater
                    {
                        model: 16
                        delegate: Loader {
                            sourceComponent: Image
                            {
                                width: 400
                                height: 300
                                source: "file:///C://MyImage1.jpg"
                            }
                        }
                    }
                }
            }
        }
    }
    

    The scrollbar is displayed on the right side of the window and I can scroll by mouse wheel.

    Now I put the code above into two columns:

    import QtQuick 2.9
    import QtQuick.Controls 2.2
    import QtQuick.Layouts 1.3
    
    ApplicationWindow {
        visible: true
        width: 800
        height: 600
    
        RowLayout
        {
            anchors.fill: parent
    
            Item
            {
                Layout.fillHeight: true
                ScrollView
                {
                    anchors.fill: parent
                    ColumnLayout
                    {
                        anchors.fill: parent
                        Repeater
                        {
                            model: 16
                            delegate: Loader {
                                sourceComponent: Image
                                {
                                    width: 400
                                    height: 300
    
                                    source: "file:///C:/MyImage1.jpg"
                                }
                            }
                        }
                    }
                }
            }
    
            Item
            {
                Layout.fillHeight: true
                ScrollView
                {
                    anchors.fill: parent
                    ColumnLayout
                    {
                        anchors.fill: parent
                        Repeater
                        {
                            model: 16
                            delegate: Loader {
                                sourceComponent: Image
                                {
                                    width: 400
                                    height: 300
    
                                    source: "file:///C:/MyImage2.jpg"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    

    Now the scrolling behaviour is strange:

    • The scrollbar for the right column is displayed on its left side overlapping the left column and it is not possible to scroll the column by the mouse wheel. The scrolling is possible by holding the scrollbar slider only.
    • The scrollbar for the left column is not displayed at all (or it is displayed outside the window on the left side) and again the scrolling is not possible by the mouse wheel.

    I'd expected both scrollbars would be displayed on the right side of the corresponding columns and the mouse wheel scrolling should work for both columns separatelly as well.

    So my question is how to make it work?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      PetrM
      wrote on last edited by
      #2

      After some experiments I found a solution, see the code below. To tell the truth I don't know why this code works and the code above does not.

      import QtQuick 2.9
      import QtQuick.Controls 2.2
      import QtQuick.Layouts 1.3
      
      
      ApplicationWindow {
          visible: true
          width: 800
          height: 600    
      
          RowLayout
          {
              anchors.fill: parent
              ScrollView
              {
                  //anchors.fill: parent
                  Layout.fillHeight: true
                  Column
                  {
                      id: col
                      Repeater
                      {
                          model: 16
                          delegate: Item
                          {
                              width: imageLeft.width
                              height: imageLeft.height
                              Image
                              {
                                  anchors.centerIn: parent
                                  id: imageLeft
                                  width: 400
                                  height: 300
      
                                  source: "file:///MyImage1.jpg"
                              }
                          }
                      }
                  }
              }
              ScrollView
              {
                  //anchors.fill: parent
                  Layout.fillHeight: true
                  Column
                  {
                      Repeater
                      {
                          model: 16
                          delegate: Item
                          {
                              width: imageRight.width
                              height: imageRight.height
                              Image
                              {
                                  anchors.centerIn: parent
                                  id: imageRight
                                  width: 400
                                  height: 300
      
                                  source: "file:///MyImage2.jpg"
                              }
                          }
                      }
                  }
              }
          }
      }
      
      1 Reply Last reply
      0

      • Login

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