[Solved] How to prevent recompile to see QML-changes?
-
wrote on 5 Nov 2014, 12:49 last edited by
Hi folks,
I have the following (standard) project-setup:
main.cpp-file which loads then main.qml-file
some qml-files which are placed in a resource-file (qrc)
I have done some qml-extensions in c++ how it is described here: http://qt-project.org/doc/qt-5/qml-extending-tutorial-index.htmlProblem: If I do a change in a qml-file, I don't see an effect, if I just restart the application (in Creator). I always have to recompile the code. I would expect this behaviour for changes in the C++-code, but for the QML?
What am I doing wrong?
Thanks in advance.
Best regards Kai -
wrote on 5 Nov 2014, 12:59 last edited by
Hi there.
This happens because the qml file you are editing is inside the resource file. Resource files are compiled and stay inside executable. Thus, when you modify a qml that is within resource file, the compiler needs to recompile the resource file to put within executable and recompile the executable.
I hope I have helped you.
-
wrote on 5 Nov 2014, 14:18 last edited by
So,
during development it's not a good idea to put qml's into qrc's.
Thanks a lot. Best regards
Kai -
wrote on 6 Nov 2014, 03:31 last edited by
I don't know, I like putting my qml into the qrc during development. I just click on the (big green) run button after making QML changes and it saves, compiles and builds in a few seconds so I don't consider it a hardship. At one point nested QML wasn't automatically rebuilding but in the latest releases it works. The compile only builds what it needs to (as opposed to a rebuild), so it's typically pretty fast in my experience.
-
wrote on 10 Nov 2014, 15:04 last edited by
I also put qml files into qrc right from the start.
In addition I hook up a shortcut F5 to reload qml from disk. This way I can edit qml files and instantly see the changes in the running application.
My shortcut reload slot has the lines
@
view->engine()->clearComponentCache();
view->setSource(
QUrl::fromLocalFile("c:/path/to/main.qml"));
@It's after setting up this you really get to experience the Quick in QtQuick :-)
I used to believe it was about rendering performance, but it's as much about developer productivity. -
wrote on 14 Nov 2014, 21:07 last edited by
Thanks again, it is always a pleasure to get such qualified answers.
- I had this strange misbehaviour, which I described in my first post.
- To test the problem again, I started the same project from scratch.
This time the problem did not occur. So I was able to see my
QML-changes at once without recompile. So I think I had a
misconfiguration in my old project or there is a (little) bug somewhere
in the build-system. - @Rolias: Same with me. Having the qml's in the qrc is comfortable. You
don't have to care for file locations and so on. - @Torgair: If I understand correctly, you bind the shortcut into every
application which you develop, so you can edit and test your qml at
runtime. Is it correct? Perfect trick.
Thanks again
Kai
1/6