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

ScrollView: interactive



  • I have problems with my QML ScrollViews in a Qt application. I can not avoid the interactive mode, even setting the property to 'false'

    For testing, I have the docu QML example loaded in a QQuickView:

    main.cpp:

    int main(int argc, char *argv[])
    {   
        QGuiApplication a(argc, argv);
    
        QQuickView* pView = new QQuickView();
        pView->setSource(QUrl("qrc:/TestScroll.qml"));
        pView->setColor("white");
        pView->setHeight(400);
        pView->setWidth(600);
        pView->show();
    
        return a.exec();
    }
    

    TestScroll.qml:

    import QtQuick 2.9
    import QtQuick.Controls 2.2
    
    ScrollView {
        width: 200
        height: 200
    
        ScrollBar.vertical.interactive: false // Not working
    
        ListView {
            model: 20
            delegate: ItemDelegate {
                text: "Item " + index
            }
        }
    }
    

    Am i doing something wrong? Is it a QT bug?

    Thanks,
    Diego



  • What do you want to achieve? Your example working fine as documentation says. Scroll bar is visible but you cannot interact with it.



  • @DiegoDonate

    Do you want completely disable the interactive ?
    Refer Touch vs. Mouse Interaction

    • If you want to disable Mouse Scroll Interaction :
        ScrollBar.vertical.interactive: false
        wheelEnabled: false
    

    wheelEnabled is property of Control .

    All the best.



  • Thanks for your messages. I think I did not explain my problem properly, sorry...

    What I need is to avoid the 'bounce' at the end of the scroll view when scrolling using the wheel. When I use the scrollBar for scrolling, I get no bounce at the end of the scrolling screen

    Thanks,
    Diego



  • Then boundsBehavior property of ListView is what you need. Also, ScrollView is not mandatory here, ListView is Flickable as itself. Example:

            ListView {
                width: 200
                height: 200
                ScrollBar.vertical: ScrollBar {
                    interactive: false
                }
                model: 20
                boundsBehavior: ListView.StopAtBounds // Disable bouncing
                delegate: ItemDelegate {
                    text: "Item " + index
                }
            }
    


  • @IntruderExcluder said in ScrollView: interactive:

    boundsBehavior: ListView.StopAtBounds // Disable bouncing

    Thanks, it works for my ListViews! However, I also need to disable bouncing in 2 ScrollViews with content, but no Listview... Is it possible?



  • For some reason there is no way to set such property or get access to inner flickable (at least without rebuilding Qt). Probably your way is to use Flickable instead of ScrollView.



  • @IntruderExcluder Thanks for your help


Log in to reply