QML component not recognized when loading from local file
-
@nwoki Can you check if one of the following way works for you?
https://forum.qt.io/topic/57604/qrc-main-qml-9-gui-delegates-uepeopleitemdelegate-qml-no-such-directory-error/2 -
@p3c0 The QML files are in a folder on the desktop whilst my program is run from a different folder. The result i'm trying to achieve is that of being able to load a qml program (any folder with a bunch of QML files in it starting from a "main.qml" file) from any folder.
Yes, I use plugins but they're custom QML plugins (qqmlcomponent). Do they somehow interfere with the loading of the qml files on my desktop folder? (I use a seperate QQmlEngine for these components)
-
The result i'm trying to achieve is that of being able to load a qml program (any folder with a bunch of QML files in it starting from a "main.qml" file) from any folder.
Use a Loader and set the source to a main area of that said extra folder
example:
/home/nwoki/mainApp/ This is the folder that contains your main app. that app that is run when main.cpp inits the engine or view or whatever. Add a Loader here and get the url (for other folder )and store in c++ sa a QString or whatever
then there is this folder
/home/nwoki/Videos/QmlVideosFolder/Just map the Loader to Load from there.
-
@p3c0 said in QML component not recognized when loading from local file:
@nwoki Can you try without setting the
baseUrl
and in the following manner:QQuickView view; view.setSource(QUrl::fromLocalFile(QStringLiteral("/home/folder/main.qml")));
This was the fix. More precisely:
QUrl::fromLocalFile
I was loading the non qrc files without the "QUrl::fromLocalFile". Using this solved the qml resolve problems and I'm now able to load the extra QML components from the specified dir.
Thanks guys :)
-