How to set dynamically created component to the Loader.



  • I am creating new QML screen using following code.

    @
    var newComp = Qt.createComponent("test.qml");
    var newObject = newComp.createObject(parent, {"x": 0, "y": 0});
    @

    I wan to set this component to the loader.
    I have tried to do it using "Loader.sourceComponent = newObject;" it works but it gives me following error.

    "Error: Cannot assign QObject* to QDeclarativeComponent*"

    Is there any workaround for this.

    Thanks.

    [EDIT: code formatting, Volker]


Log in to reply
 

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