05 – Enable build time checks for your QML files

Table of Contents

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


Post history - Last 5 commits

17/02/2020 09:47:52 - Small formatting change (Frank Meerkötter)

14/02/2020 14:08:33 - Give all tools a number prefix to allow for sorting The number prefix is the same as the card number. (Frank Meerkötter)

Leave a Reply

Your email address will not be published. Required fields are marked *

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on xing
Share on email
Share on stumbleupon
Share on whatsapp
Share on pocket