Qt 6.5 QML-in-QRC vs qt_add_qml_module. What is better?
-
Hello!
Just got confused with new Qt functionality qt_add_qml_module() The question is about what is better to use? In official documentation mentioned that both ways could be used in Qt 6.5. But what is preferable and why?
For now all of projects maintained by me using QML-in-QRC and really don't know why it should be changed on qt_add_qml_module() functionality.
-
I am asking myself the same question - I think I read somewhere that adding qml files as well as image resources with qt_add_qml_module() is really the preferred way (because of linting, cachegen and so on) - I think it was in one of the qt blog post regarding this topic.
My main concern is that this really clutters the CMakeLists when you have many files. -
I am asking myself the same question - I think I read somewhere that adding qml files as well as image resources with qt_add_qml_module() is really the preferred way (because of linting, cachegen and so on) - I think it was in one of the qt blog post regarding this topic.
My main concern is that this really clutters the CMakeLists when you have many files.qt_add_qml_module() is indeed the way to go, as it standardizes a lot of things, and therefore makes qml more toolable.
For the 'cluttering' aspect, you can use include() and CMake variables to separate things if you want to. But personally, I think the list of files is the core of a build system, so I think 'hiding' it in a separate .qrc file is actually a bit of a misfeature ;)
-
qt_add_qml_module() is indeed the way to go, as it standardizes a lot of things, and therefore makes qml more toolable.
For the 'cluttering' aspect, you can use include() and CMake variables to separate things if you want to. But personally, I think the list of files is the core of a build system, so I think 'hiding' it in a separate .qrc file is actually a bit of a misfeature ;)
@kkoehne But what about security? If there are using of qt_add_qml_module() will be it stored in application in plain QML text or it will be transformed in C++? Haven't found any info about it in any manuals? Main reason of using *.qrc within QML were security. It was making harder process of reading QMLs.
-
qt_add_qml_module() is indeed the way to go, as it standardizes a lot of things, and therefore makes qml more toolable.
For the 'cluttering' aspect, you can use include() and CMake variables to separate things if you want to. But personally, I think the list of files is the core of a build system, so I think 'hiding' it in a separate .qrc file is actually a bit of a misfeature ;)
-
@kkoehne But what about security? If there are using of qt_add_qml_module() will be it stored in application in plain QML text or it will be transformed in C++? Haven't found any info about it in any manuals? Main reason of using *.qrc within QML were security. It was making harder process of reading QMLs.
@bogong said in Qt 6.5 QML-in-QRC vs qt_add_qml_module. What is better?:
But what about security? If there are using of qt_add_qml_module() will be it stored in application in plain QML text or it will be transformed in C++? Haven't found any info about it in any manuals? Main reason of using *.qrc within QML were security. It was making harder process of reading QMLs.
qt_add_qml_module() allows to use the Qt Quick Compiler , which actually generates C++ code: https://www.qt.io/blog/the-new-qtquick-compiler-technology . If it can't be used, it falls back to qrc though.
(But please note that embedding QML sources in the binary via qrc is obfuscation as best. It's not rocket science to extract the sources back if you have access to the binary).
-
@kkoehne good to know. Does qmake have the similar setting? a qrc file would be able to be applied in both qmake and cmake files, right? Or you guys are dropping qmake?
@JoeCFD said in Qt 6.5 QML-in-QRC vs qt_add_qml_module. What is better?:
Does qmake have the similar setting? a qrc file would be able to be applied in both qmake and cmake files, right?
qmake does miss the high level abstraction for QML modules. But if you're asking whether you can embed qml files without a .qrc file ... you can:
assets.files = file1.qml file2.qml assets.prefix = / RESOURCES += assetsOr you guys are dropping qmake?
Not any time soon :) But we don't develop it much further.
-
@JoeCFD said in Qt 6.5 QML-in-QRC vs qt_add_qml_module. What is better?:
Does qmake have the similar setting? a qrc file would be able to be applied in both qmake and cmake files, right?
qmake does miss the high level abstraction for QML modules. But if you're asking whether you can embed qml files without a .qrc file ... you can:
assets.files = file1.qml file2.qml assets.prefix = / RESOURCES += assetsOr you guys are dropping qmake?
Not any time soon :) But we don't develop it much further.
-
E EwaldVDM referenced this topic