basysKom Toolbox

05 – Enable build time checks for your QML files

Enable build time checks for your QML files

Goals

Find QML issues already at build time.

Description

QML is weakly typed – issues might only show up during runtime when a document is actually loaded. Qt is offering several ways to improve this situation. Use either qmllint or the Qt Quick compiler to catch syntax errors already during build time. Consider adding this to your CI system to make the most out of it.

Environment

Qt/QML

Platform

All

Implementation effort

Low

Applicability

All QML projects.

Caveats

Note that both, qmllint and the Qt Quick Compiler can only catch things that do not rely on specific execution context such as syntax errors.

See also

Continuous Integration keeps your project healthy

Implementation hints

qmllint has been added with Qt5.4. The Qt Quick compiler has been available in upstream Qt since Qt5.11.

Ideally these tools are run as part of the build process.

Given that you are already using QRCs for your QML documents you can just add CONFIG+=qtquickcompiler to your project.

For CMake and more details see: https://doc.qt.io/qt-5/qtquick-deployment.html#ahead-of-time-compilation

About the Toolbox

The basysKom Toolbox is a state-of-the-art collection of best practices in agile management and software development and a valuable tool for every kickoff meeting.

These cards can be used during a project kickoff in order to select best fitting good practices from the very start of your project, but also as a reminder during the course of a project implementation. Every card holds a QR code with additional information related to the specific tool, the tools’ applicability, known constraints and additional tips on how to implement it in a project setup.

You can provide us feedback on GitHub.

Toolbox

basysKom Newsletter

We collect only the data you enter in this form (no IP address or information that can be derived from it). The collected data is only used in order to send you our regular newsletters, from which you can unsubscribe at any point using the link at the bottom of each newsletter. We will retain this information until you ask us to delete it permanently. For more information about our privacy policy, read Privacy Policy