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

Use ScrollBar when "import QtQuick.Controls 2.0 as 'SomeTag'"



  • Hi everybody,
    I have a problem when I'm trying to add a ScrollBar in a Flickable.
    My problem is that I import QtQuick.Controls 2.0 as => "import QtQuick.Controls 2.0 as 'SomeTag'" because I want to differentiate between QtQuick.Controls 1.4.

    The example in the doc is like this:

    Flickable {
        // ...
        ScrollBar.vertical: ScrollBar { }
    }
    

    But to fit in my Code I have to use:

    import QtQuick 2.7
    import QtQuick.Controls 2.0 as Phone
    import QtQuick.Controls 1.4 as Desktop
    
    Phone.Page{
        title: "MyPage"    
        Flickable {
            id: flickable       
            anchors.fill: parent
            contentHeight: flickableChildItem.height
            boundsBehavior: Flickable.StopAtBounds
            Phone.ScrollBar.vertical: Phone.ScrollBar{}
        }//Flickable
    }//Page
    

    When I try to run my code, this problem appears:

       qrc:/QML/MyPage.qml:7:5: Cannot assign object to read only list
    

    I would like to keep this:

    import QtQuick 2.7
    import QtQuick.Controls 2.0 as Phone
    import QtQuick.Controls 1.4 as Desktop
    

    Because sometimes I like to use some QtQuick.Controls 1.4 Item.

    Thank you very much


Log in to reply