C

Building Qt Quick Ultralite application as a static library

This topic provides an instructions to build a Qt Quick Ultralite application as a static library and integrate it with an external project.

Building as a library

Qt Quick Ultralite lets you build an Qt Quick Ultralite application as a static library by using the qul_add_target CMake function. This function builds an excutable target by default, unless the STATIC_LIBRARY option is added to the arguments list. See the following example:

qul_add_target(example_app
               STATIC_LIBRARY
               source1.cpp
               source2.cpp)

If app_target_default_entrypoint is set up in the CMake project file, the qul_run.h header file is genearted and copied to the libraries output directory. The header contains the qul_run() function, which will be the Qt Quick Ultralite application's entrypoint.

app_target_default_entrypoint(<target> <item>)

Where, target is the target created by the qul_add_target CMake function and item is the name of QML file, which will be the Qt Quick Ultralite application's entrypoint.

Integrating the static library with an external project

To integrate the Qt Quick Ultralite application library with an external project, link the external project against it, along with all the used Qt Quick Ultralite libraries. In addition, copy or add the Qt Quick Ultralite include path to the external project's include path. if the Qt Quick Ultralite application provides a default entrypoint, copy or add the genearted qul_run.h header file path to the external project's include path.

Next, reuse the existing Qt Quick Ultralite platform abstraction code in external project, or create a new one for your target board. See Qt Quick Ultralite Platform Porting Guide for more information.

Finally, create an entrypoint function in the external project based on the Entry point to Qt Quick Ultralite application guide. When default entrypoint is used, include the qul_run.h header file and call the qul_run() function at the desired location to initialize and start the Qt Quick Ultralite engine.

After calling the qul_run() function, the control jumps to Qul::Platform::exec(), which is specific to each platform abstraction. All implementations of this function for the platform abstraction examples delivered with Qt for MCUs contain an infinite while loop. This means that the rest of the non-UI code must either be moved to the corresponding Qul::Platform::exec() implementation or it must be interrupt-based.

If external project is using RTOS, Qt Quick Ultralite could be run in separate thread. In such a case user need to provide a thread-safe interface with Qt Quick Ultralite, as the embedded event system cannot be updated directly from other threads.

Available under certain Qt licenses.
Find out more.