C

Build process overview

The Qt Quick Ultralite toolchain is built around CMake. The build process starts with the CMake configuration phase where application's CMakeLists.txt, Qt Quick Ultralite package's CMake files and platform specific toolchain.cmake files are used to prepare build files. The actual build process depends on the selected CMake generator.

The Qt Quick Ultralite build process is demonstrated with an example application that connects over Bluetooth to a mobile phone and fetches a contact list. The project includes the following files:

FileDescription
Main.qmlMain application view
Contacts.qmlA contacts list view that is based on ListView and a model exposed by BluetoothWrapper.qml
ContactDelegate.qmlA delegate that renders a single contact
BluetoothWrapper.h/cppA custom QML element that wrapps around bluetooth.h and exposes contacts model as well as methods to get a list of available Bluetooth devices. The element also set ups connections and fetches the contact list.
bluetooth.h/cContains low level code for handling Bluetooth stack
avatar.pngAn image asset that is used as decoration within ContactDelegate.qml
font.ttfCustom font that are used across the application to render texts
CMakeLists.txtA project configuration file

The following diagram provides an overview of the example application's build process:

Generating code with Qt Quick Ultralite tools

Qt Quick Ultralite provides tools that generate the required additional code. For more information, see qmlinterfacegenerator, qmltocpp, and fontcompiler.

qmlinterfacegenerator

qmlinterfacegenerator parses C++ header files for custom QML elements. For example, this is done to provide a connection between QML and application business logic layers. In the example application, BluetoothWrapper.qml is generated out of BluetoothWrapper.h file.

qmltocpp

The qmltocpp tool provides the following functionality:

  • It builds a QML object model out of provided qml files. Input for the qmltocpp tool is as follows:
    • Application's QML code. In the example, the QML code contains Main.qml, Contacts.qml, and ContactsDelegate.qml.
    • The files that are generated by qmlinterfacegenerator
    • The Qt Quick Ultralite interface files that correspond to the Qt Quick QML elements or controls. For example, Item.qml, Rectangle.qml, Image.qml, ListView.qml, PropertyAnimation.qml, Slider.qml, and Button.qml.
  • It analyzes graphical assets that are used in the QML application code and generates optimized raw data buffers out of them. In the example, qmltocpp generates avatar.png. The optimization process depends on a platform, a configuration, and usage. For example, optimization can result in lowering color depth, replacing with alphamap, removing outline transparent areas, and swizzling.
  • It analyzes usage of text elements and builds the FontMeta database. The database provides input for the fontcompiler tool.
  • It replaces the JavaScript code with generated C++ code.
  • It generates bindings, states, and transitions code.
  • It combines all above and generates C++ header and source files. In the example, qmltocpp creates the following files:
    • Main.h/cpp
    • Contacts.h/cpp
    • ContactDelegate.h/cpp
  • If the pragma main statement is found in one of the .qml files, the int main() function is generated. It contains the required startup code.

fontcompiler

fontcompiler generates raw font glyphs that are embedded into application code. The embedding is done on basis of the font metadata that is created by the qmltocpp tool. The font metadata contains the following information:

  • glyphs that are generated for characters that are potentially displayed on the application user interface.
  • desired font. In the example, the font is font.ttf.
  • font style, such as size, weight, decoration.

The outcome of the fontcompiler tool is found on the qul_fonts.cpp file.

Compilation phase

After the additional code is generated, the compilation starts. Input for a compiler is as follows:

  • The application's c++/c code. In the example application, the code includes bluetooth.h/c and BluetoothWraper.h/cpp.
  • The generated files. In the example, Main.h/cpp, Contacts.h/cpp, ContactDelegate.h/cpp, and qul_fonts.cpp were gererated.
  • The Qt Quick Ultralite public and internal headers. For example, the headers are provided for templated classes, such as Property, Signal, or for items, such as Rectangle and Image.

Linking against Qt Quick Ultralite libraries

Finally, you need to link statically against the Qt Quick Ultralite libraries. Depending on your target platform, linking provides the following outcome:

  • An application executable if your target platform is desktop.
  • An image file, such as *.elf, *.hex, *.run, that you can flash into your target device on all MCUs platform.

Available under certain Qt licenses.
Find out more.