Qml component child of qml engine on different path
Solved
General and Desktop
-
Hi all!
I need some soggestion...
I have some core qml element inside the resource path (qrc:/Foo.qml) and other qml element out of this (file:///home/main.qml)The qml engine that I need to use an main.qml similar this:
Rectangle {
id: optContainer
foo {
id: tmp
}
}I thought to use a component in that way: QQmlComponent component(pEngine, QUrl(QStringLiteral("qrc:/Foo.qml"))); and after that try to add this component inside the QQmlApplicationEngine... but I don't understand how to do this...
Any suggestions?? :)
Thanks a lot
-
@Arsiero IMO one way would be after creating the object you can set
optContainer
as its parent using setParentItem.QQmlComponent component(engine, QStringLiteral("qrc:/Foo.qml")); QQuickItem *childItem = qobject_cast<QQuickItem*>(component.create()); childItem->setParentItem(containerObj); //This will be optContainer's instance from accessed in C++