Is well know qml compiler became available also to open source version for some time now. The procedure for compile qml source is explained here. Is possible to verify that compiler work as expected by checking the generated sources. For example if you have a file named mycode.qml you should find the corresponding .._.._mycode_qml.cpp source (generated by the QML compiler) and relative compiled .obj (on Windows obviously). Explained this, however, I just noticed the (compiled) qml sources code are still clearly visible inside the generated executable (or a .so library in caso of Android compilation) by just using a simple text editor like Notepad++. I suppose because they are integrated as resources but I hope I did something wrong because the usefulness of compiling the qml sources is precisely to hide the code as well as improve performance. Also in the official explanation linked above this should not happen since it says "After activating the Qt Quick Compiler in the build integration, the build system will automatically execute the tool to compile your .qml and .js files into the binary and avoid the inclusion of their source code in the resource system." My environment is Qt version 5.15.2 and Qt Creator version 4.13.2.
test.pro
QT += quick
CONFIG += c++11
SOURCES += \
main.cpp
RESOURCES += qml.qrc
qml.qrc
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}
main.qml
import QtQuick 2.12
import QtQuick.Window 2.12
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
}
Can anyone help me figure out what I am doing wrong?
Thank you
CONFIG += qtquickcompiler.