Problem with Qt Quick imports



  • Hi,

    I've got another question, this time regarding QML imports. I want to use a ScrollView and a SwipeView in the same QML file.
    I'm using Qt 5.7 and reading the docs for the ScrollView it says to import QtQuick.Controls 1.4. The docs for the SwipeView tell me to import QtQuick.Controls 2.0 .

    In my naivety I used the last import, thinking it would give access to both components. However ScrollView is not available with QtQuick Control 2.0 and I can't import both versions either. Can I get this to work without splitting the code into separate QML files?

    Thanks in advance!



  • Hello @MrBolton,

    Is it possible for you to use à Flickable (or ListView/GridView) instead of a ScrollView?



  • You can use qualified (namespace) module imports.

    import QtQuick.Controls 1.4 as QQC1
    import QtQuick.Controls 2.0 as QQC2
    
    QQC2.ApplicationWindow {
        QQC1.ScrollView {
            // ...
        }
    }
    

    Alternatively, you could use a Flickable with ScrollIndicator or ScrollBar from Qt Quick Controls 2...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.