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

Qml Singleton with AutoComplete(IntelliSense)



  • Hello,

    I want to use qml Singleton in my project and I can't get AutoComplete to work.

    //Styles.qml
    pragma Singleton
    import QtQuick 2.11
    
    QtObject {
        property QtObject cars: QtObject {
            property string luxury: "bmw"
            property string exotic: "ferrari"
        }
    }
    
    

    I register singleton:

        qmlRegisterSingletonType(QUrl("qrc:///singletons/Styles.qml"), "My.Examples", 1, 0, "Styles");
    
    import QtQuick 2.11
    import QtQuick.Window 2.11
    import My.Examples 1.0
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        Text {
            text: Styles.cars.exotic
        }
    }
    

    I get the expected output "ferrari" but when I type Styles. I should get a dropdown where I could select cars but it doesn't work.


  • Qt Champions 2017

    It is issue with editor. It may have difficulty in recognising the type. Hence the issue.


Log in to reply