Reputation: 359
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.
Upvotes: 1
Views: 2010
Reputation: 2590
Loader.sourceComponent has to be a Component, so
Loader.sourceComponent = newComp
should work.
But this is pretty much the same as
Loader {
source: "test.qml"
}
Upvotes: 3