1

I'm trying to create a Scrollbar for a rectangle that holds automatically generated rectangles , i want the scrollbar to stop when i scroll down if there are no more rectangles to view, same thing for scroll up, i have serached the internet and found most examples talks about listview whereas i'm not using that , i have tried using the Flickable component but it didn't work out for me

here is my code:

 Flickable {
id: flickArea
anchors.fill: parent
contentWidth: cRects.createRects(w).width; contentHeight: cRects.createRects(w).height
flickableDirection: Flickable.VerticalFlick
clip: true

Rectangle {
    id: rectangle17
    x: 127
    y: 107
    width: 200
    height: 200
    color: "#ffffff"
    opacity: 0





    Item {
    id: cRects



            function createRects(w) {

                var z = 10
                var t = 20
                var itemList = []
              /*  if(w == 2)
                    z = 60*/
                for (var i = 0; i < w; i++) {

                    itemList[i] = Qt.createQmlObject(
                                'import QtQuick 2.0; Rectangle { width: 325; height: 35;'
                                + ' x: ' + t + '; y: ' + z + '; color: "#ffffff"; radius: 32;  border.width: 2; border.color: "#ada9a9"  }',
                                rectangle17, "createItems()");

                    z = z + 40
                   // t = t - 40
                }
                return itemList
            }
            //property variant items: cRects.createItems()


       }


    }


}

Any ideas on how this can be fixed

thanks

m7md
  • 81
  • 1
  • 1
  • 8

1 Answers1

0

today I cant help you since I cant access to my QT in my computer, tomorrow at work will try to have a look, but just reviewing the documentation,

boundsBehavior : enumeration

This property holds whether the surface may be dragged beyond the Fickable's boundaries, or overshoot the Flickable's boundaries when flicked. This enables the feeling that the edges of the view are soft, rather than a hard physical boundary. The boundsBehavior can be one of:

  • Flickable.StopAtBounds - the contents can not be dragged beyond the boundary of the flickable, and flicks will not overshoot.

  • Flickable.DragOverBounds - the contents can be dragged beyond the boundary of the Flickable, but flicks will not overshoot.

  • Flickable.DragAndOvershootBounds (default) - the contents can be dragged beyond the boundary of the Flickable, and can overshoot the boundary when flicked.

from: http://qt-project.org/doc/qt-4.8/qml-flickable.html#atYEnd-prop

David Sánchez
  • 544
  • 8
  • 21