
Originally Posted by
anda_skoa
I meant qmlRegisterSingletonType()
However, there might be another option that is closer to what you tried.
I assume you are using QQmlComponent to create the UI. You can pass a context to its create method.
_
I'm using the following to create the main UI (i.e. loading main.qml). It is in this view that I want to load the plugins QML components:
QGuiApplication app(argc, argv);
QQuickView viewer;
viewer.
setSource(QUrl("qrc:///..."));
viewer.showExpanded();
return app.exec();
QGuiApplication app(argc, argv);
QQuickView viewer;
viewer.setSource(QUrl("qrc:///..."));
viewer.showExpanded();
return app.exec();
To copy to clipboard, switch view to plain text mode
Also, I found this thread that seems pertinent to my problem. However, I cannot fully comprehend it. Specifically, what are window1, window2 & window3 in the given solution.
How do I create my main UI using QQmlComponent and later add the QQmlComponent created using the method you specify to the main UI's QQmlComponent? I found a possible implementation here. But when I run it, I get a crash because:
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
To copy to clipboard, switch view to plain text mode
evaluates to window = NULL
Bookmarks