ChriD
31st January 2016, 15:42
I want to create a QML Comonent on runtime.
I found some samples and i tried it, but i am not always getting an abortion when laoding the URL into the component.
I tried several URLs to be sure i got a working one but i always get the abortion (read acces Violation) which i thought is a Problem when getting the qml file.
QQmlComponent *component = new QQmlComponent(viewController.getAppEngine().data() );
//component->loadUrl(QUrl("qrc:///qml/components/LabelStringEdit.qml")); // ABORTION IS HERE!!! This line should work in my opinion...
//component->loadUrl(QUrl("qrc:/qml/components/LabelStringEdit.qml"));// ABORTION IS HERE!!!
//component->loadUrl(QUrl("qrc:module/settings/view_settings_connector_sageX3.qml"));// ABORTION IS HERE!!!
component->loadUrl(QUrl::fromLocalFile("C:/Development/QtTest/qml/components/LabelStringEdit.qml")); // ABORTION IS HERE!!!
QQuickItem *quickItem = qobject_cast<QQuickItem*>(component->create());
QQuickItem *parentQuickItem = qobject_cast<QQuickItem*>(_rootObject);
QQmlEngine::setObjectOwnership(quickItem, QQmlEngine::CppOwnership);
quickItem->setParent(this);
quickItem->setVisible(true);
quickItem->setParentItem(parentQuickItem);
Is there anything i am doeing wrong?
The QML is a Quck QML file...
Thanks!
I found some samples and i tried it, but i am not always getting an abortion when laoding the URL into the component.
I tried several URLs to be sure i got a working one but i always get the abortion (read acces Violation) which i thought is a Problem when getting the qml file.
QQmlComponent *component = new QQmlComponent(viewController.getAppEngine().data() );
//component->loadUrl(QUrl("qrc:///qml/components/LabelStringEdit.qml")); // ABORTION IS HERE!!! This line should work in my opinion...
//component->loadUrl(QUrl("qrc:/qml/components/LabelStringEdit.qml"));// ABORTION IS HERE!!!
//component->loadUrl(QUrl("qrc:module/settings/view_settings_connector_sageX3.qml"));// ABORTION IS HERE!!!
component->loadUrl(QUrl::fromLocalFile("C:/Development/QtTest/qml/components/LabelStringEdit.qml")); // ABORTION IS HERE!!!
QQuickItem *quickItem = qobject_cast<QQuickItem*>(component->create());
QQuickItem *parentQuickItem = qobject_cast<QQuickItem*>(_rootObject);
QQmlEngine::setObjectOwnership(quickItem, QQmlEngine::CppOwnership);
quickItem->setParent(this);
quickItem->setVisible(true);
quickItem->setParentItem(parentQuickItem);
Is there anything i am doeing wrong?
The QML is a Quck QML file...
Thanks!