Qt Quick Compiler

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. When you use this add-on, the application's startup time is significantly improved and you no longer need to deploy .qml files together with the application.


Qt Quick enables rapid development cycles for your applications. This is accomplished by doing away with the traditional C++ compilation step. Instead, we load the .qml source code on demand at run-time. The popular Just-in-time (JIT) compilation technique is used to generate machine code on the fly, which speeds up the execution of JavaScript and QML binding expressions.

Unfortunately this approach has some disadvantages: On application startup, several .qml files need to be parsed and dynamically compiled before the user interface can become visible and interactive. This is rarely a problem during application development itself, however it is an unnecessary step for a finally released application, as the ability for the end user to modify the qml source code like a developer is usually not required. Conceptually, this is similar to how a release build of C++ code cannot be used with a debugger.

As .qml files are loaded at run-time, it is necessary to deploy them together with the released application. For proprietary applications that wish to hide the source code from the end user, this is an unacceptable restriction.

Lastly, some platform versions such as iOS (version 7 and earlier) or Windows RT do not permit the dynamic generation of machine code. As a fallback QML provides an interpreter to allow for the full use of QML, but it comes at the expense of a longer execution time.

Compiled Qt Quick is an elegant solution to these problems: .qml files as well as accompanying .js files can be translated into intermediate C++ source code. After compilation with a traditional compiler, the code is linked into the application binary. This entirely eliminates the need of deploying QML source code, it reduces the application startup time and allows for a much faster execution on platforms that do not permit Just-in-time compilation.

Getting Started

The Qt Quick Compiler package consists of the compiler as a command line tool as well as a build system integration.

The integration into the build system happens at the level of the Qt Resource System. In order to use the Qt Quick Compiler, your application needs to be prepared:

  • Create a .qrc file for your application and include all the files your project needs, including .qml , .js and qmldir files.
  • Add the file name of your .qrc file to RESOURCES in your .pro file.
  • Change your application to use qrc: URLs instead of file: in order to become file system independent.
  • This way all dependent files are bundled into your application binary and you should verify that your application works without the .qml source code in the file system.

When your application has been converted to use the Qt Resource System, you can activate the integration with the Qt Quick Compiler by passing CONFIG += qtquickcompiler to qmake, for example on the command line or in the build settings of your project in Qt Creator, as additional argument in the qmake build steps.

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.

If you are building your application with the CMake build tool, then the same principles of using the resource system apply. See the separate Building with CMake article for details about the CMake specific syntax.


Available under certain Qt licenses.
Find out more.