Load from absolute path
-
Hi,
I would like to know if anyone has recently ( 5.12 -5.15) tried to load a Qml file from an absolute path, rather than from the resource system.It works fine on MacOS.
But for the life of me, on windows I always get the "QQmlApplicationEngine faild to load component" messageI would like to know if I'm doing something silly, or if thats actually somehow broken 🤷♂️
I should have added code from the beginning ;)
gir repo: -
-
It works here, try putting an example of what you tried.
I tried with this url :
QUrl url(QStringLiteral("file:///D:/coding/untitled30/main.qml"));
-
Thank @fcarney and @GrecKo for your time in testing this,
From what I can see now - I 'm at home now and don't have a Windows Pc to check - I was being silly!
I relied on QUrls auto deduction, of a local file path. That happen to work on unix systems but of course not on windows.
So changing my code from
engine.load(QUrl(QString(QMLSOURCEDIR )+ "/main.qml"));
to
engine.load(QUrl::fromLocalFile(QString(QMLSOURCEDIR )+ "/main.qml"));
like @fcarney suggested, should solve the problem cross platform 👍
It works here, try putting an example of what you tried.
I appended my opening post with a link to a git hub project, where the "problem" originated from
This should solve the issue, but I can't test it right now, I'll close the topic as soon as I verified it!
Thanks!