[SOLVED] How to use qt resources file containing .js and .qml files (Qt Quick 2 qmake project) to avoid full rebuild after every change in files?
I have Qt Quick 2 project. I need to implement computer graphics lab: drawing ellipses with different algorithms. I decided to separate ui from algorithms and created ellipse.js file.
As I understand there are 2 ways to use .qml and .js files: directly and as a qt resource part.
Disadvantages of those ways:
I must copy files to build dir (or make symlinks). I should do it every time I create a new .qml or .js file, I can forget about it.
Final user will have binary file and .qml files. Even in the case of free (open-source) software sometimes better to have single file.
I have to edit my .qrc file every time I create a new .qml or .js file.
Due this "bug":https://bugreports.qt-project.org/browse/QTCREATORBUG-1627 I have to rebuild whole project after every change in .qml or .js files.
I prefer the second way, but frequent protracted rebuilds are annoying. This is really bad because Qt Quick was presented as a solution for fast prototyping, but if I have to wait ten seconds for compilation and linking after each iteration it isn't "fast prototyping". So I switched to the first way with ugly qml files loading:
@QQmlComponent component(&engine, QUrl::fromLocalFile("../../main.qml"));@
Are there ways to fix this situation? I heard about QBS but it's unstable yet.
I also saw some examples with .qmlproject files like:
but I cannot find how to use those .qmlproject files instead of .pro files.
UPD: for pure QML projects it's worth to use .qmlproject (see below how)
I believe with this bug it should be sufficient to run qmake again and then build.
The .qmlproject file works for a pure qml project. It can be run with the qmlviewer or qmlscene depending on your QtQuick version.
To see this work, in QtCreator simply create a Qt Quick 1 UI or Qt Quick 2 UI project in stead of Qt Quick application. This has the benefit of not needing to compile at all.
Thank you, JapieKrekel, I did it and now it works fine! Program starts faster than before (but unfortunately slower than Qt Widgets application) and after changes I have to only press “Run”.
I have one problem: I used Qt Fusion Style, not system style. How can I do this with qmlscene? I created "separate thread":https://qt-project.org/forums/viewthread/27602/ for this question.