Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to know if ScrollView is at End?



  • I have several views with an scrollable area and I need to mark them as scrollable as long as there is an area below. This will be done showing an indicator as long as we are NOT at the end of the scrollable area.

    These scrollable views are done in different ways: scrollView, ListView, GridVew, Flickable, etc.

    I have seen that I can know if I'm at the end with "atYEnd" property, but this is only available for flickable-like types (listView, gridView).

    How can I achieve the same information in the case of ScrollView?



  • Hi,
    @Adso4 said in How to know if ScrollView is at End?:

    How can I achieve the same information in the case of ScrollView?

    can be done like this

    Window {
        width: 800
        height: 600
        visible: true
    
        ScrollView {
            id:view
            width: 200
            height: 200
            clip: true
    
            property bool end : false
            onEndChanged: console.log("end : " + end )
    
            property var childRect  : view.contentItem.childrenRect
            property var _y : childRect.y
    
            on_YChanged: {
                end = childRect.height + _y === view.height
            }
    
              Label {
                id:first
                text: "ABC"
                font.pixelSize: 224
            }
        }
    }
    

Log in to reply