Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt 5.11+ : How to use Qt Quick Compiler? (Qt Open Source Version)



  • Hi. I have seen Qt 5.11+ supports QtQuickCompiler anymore: http://doc.qt.io/qt-5/whatsnew511.html#qt-qml-module
    I read QtQuickCompiler documentation but I can't use it. The documentation says:

    Create a .qrc file for your application and include all the files your project needs, including .qml , .js and qmldir files.

    But there is already an qml.qrc file when we create an qqc2 project:
    alt text
    I added CONFIG += qtquickcompiler parameter to .pro file but I get this error message when I compile my app:

    Cannot find the androiddeploy Json file.
    Error while building/deploying project qqc2-test-project (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.11.0 for Android armv7))
    When executing step "Deploy to Android device"
    

    It is compiling when I choose Desktop but not Android.
    How can I use QtQuickCompiler for Android?
    How can I understand that QtQuickCompiler is working?
    Thanks.


  • Lifetime Qt Champion

    Hi,

    The error you are posting looks completely unrelated to QtQuickCompiler. It rather looks like your Android development setup is somehow broken.



  • @SGaist It's compiling and running for Android when I remove CONFIG += qtquickcompiler from .pro file. There is no problem for Android settings.
    Edit: Interesting! I can compile it now.
    Well, how can I understand that is QtQuickCompiler running?


  • Lifetime Qt Champion

    @Ibrahim said in Qt 5.11+ : How to use Qt Quick Compiler? (Qt Open Source Version):

    Well, how can I understand that is QtQuickCompiler running?

    I don't understand that question, can you rephrase it ?



  • @SGaist
    I mean I wrote CONFIG += qtquickcompiler and compiled but what changed?
    Example of:
    If I compiled my app for desktop without CONFIG += qtquickcompiler, result is this:
    alt text
    If I compiled my app for desktop with CONFIG += qtquickcompiler, result is this:
    alt text
    If I compiled my app for Android without CONFIG += qtquickcompiler, result is this:
    alt text
    If I compiled my app for Android with CONFIG += qtquickcompiler, result is this:
    alt text
    I don't understand that what happened when I put CONFIG += qtquickcompiler parameter? Because both with QtQuickCompiler and without QtQuickCompiler I can see QML files (such as OpacityMask.qml) and shared files (such as libQt5Core.so). I have read QtQuickCompiler documentation and it says:

    The Qt Quick Compiler is a development add-on for Qt Quick applications which allows you to compile QML source code into the final binary.

    But I can see there iare still QML files and libQt5xxx.so files.


  • Moderators

    @Ibrahim
    IIRC you dont see any result directly.
    Your qml files are in-place replaced with .qmlc files in the final qrc binary.



  • @raven-worx

    final qrc binary

    What do you mean? I compiled my app with release mode but apk still includes xxx.qml files and libQt5xxx.so. I can't see qmlc files.


  • Moderators

    @Ibrahimthe
    files specified in the qrc file are compiled into a cpp file by the rcc tool implicitly. thats how they are embedded into your app



  • @raven-worx Well, does QtQuikcCompiler remove libQt5xxx.so files and XXX.qml files in my apk files or desktop app? Because I can still see libQt5xxx.so and XXX.qml files in my apk file. I can see qmlcache_loader.cpp and qmlcache_loader.o files in my desktop app. Do you mean these files?
    I mean it's enough when I write CONFIG += qtquickcompiler parameter in .pro file? Don't the libQt5xxx.so and XXX.qml files from my apk have to be disappear when I compiled with CONFIG += qtquickcompiler parameter?


  • Moderators

    @Ibrahim
    are your qml files not in a qrc? But in the file system?
    See here



  • @raven-worx
    Yes, main.qml file is in the qrc. It's in qrc as default when I create an QQC2 project. Should I move main.qml to another qrc? I have not another qml files but just main.qml.



  • @Ibrahim said in Qt 5.11+ : How to use Qt Quick Compiler? (Qt Open Source Version):

    Well, how can I understand that is QtQuickCompiler running?

    Since I think, that this is still not properly answered, here is a way to test, if your build used the Qt Quick compiler:

    A benefit of the Qt Quick compiler, is that syntax errors are checked during compilation.

    So you can just put some invalid QML syntax in your qml file and test if the build finds the error during compilation (then you are using the compiler) or if the error is only found when running the application (then you are using the interpreter).

    So. e.g. put the following at the top of your main.qml and see what happens:

    imports asdf
    


  • @Ibrahim said in Qt 5.11+ : How to use Qt Quick Compiler? (Qt Open Source Version):

    Well, how can I understand that is QtQuickCompiler running?

    Since I think, that this is still not properly answered, here is a way to test, if your build used the Qt Quick compiler:

    A benefit of the Qt Quick compiler, is that syntax errors are checked during compilation.

    So you can just put some invalid QML syntax in your qml file and test if the build finds the error during compilation (then you are using the compiler) or if the error is only found when running the application (then you are using the interpreter).

    So. e.g. put the following at the top of your main.qml and see what happens:

    imports asdf

    This trick worked fine for me. In my case my problem was that I was still using in my compilation options Qt5.10, after that I have to configure CONFIG += qtquickcompiler in the build steps inside qt.

    I added CONFIG += qtquickcompiler parameter to .pro file but I get this error message when I compile my app:

    I think that this was your error, you should not define it on .pro but in the compile options steps for qmake. I can even see checkbox that indicates me if the compiler is enabled or not.
    Th


Log in to reply