I am trying to deploy windows application in Qt, so I change mode to release, but when I execute it, all it writes is
file::/qml/Main.qml: File is empty
I have already tried multiple times to rework resources.qrc, but with no success.
resources.qrc
<RCC>
<qresource prefix="/">
<file>qml/Pages/DetailPage.qml</file>
<file>qml/Pages/IntroPage.qml</file>
<file>qml/Pages/LibaryPage.qml</file>
<file>qml/Pages/Page.qml</file>
<file>qml/Pages/PageView.qml</file>
<file>qml/Controls/ControlSlider.qml</file>
<file>qml/Models/CityModel.qml</file>
<file>images/heatmapicon.png</file>
<file>qml/Main.qml</file>
</qresource>
</RCC>
I have tried to copy qml and images folder (they are in same folder as main.cpp and resources.qrc), but no success too.
This is how I set main source for QQuickView
:
view_->setSource(QUrl::fromLocalFile(QStringLiteral(":/qml/Main.qml")));
In debug mode, there is no problem and everything start as it should.
How can I change resource/code to make it work?
Thanks for your help!
//EDIT:
I have manage to solve it with view_>setSource(QUrl(QStringLiteral("qrc:/qml/Main.qml")));
You do not have to use QUrl::fromLocalFile()
, that function is indicating that you are looking for a local file, but the paths handled by a .qrc are virtual.
Use:
view_->setSource(QUrl(QStringLiteral("qrc:/qml/Main.qml")));