basysKom Toolbox

13 – Use clazy

Use clazy to avoid Qt API pitfalls

Goals

Write good Qt code. Avoid the use of problematic Qt APIs.

Description

While Qt prides itself on APIs that are consistent and simple to use – there are pitfalls. Parts of an API might turn out to be dangerous in practice or they may yield sub-optimal performance. clazy is a static code analysis tool built on to off the llvm/clang compiler infrastructure. It will issues warnings for Qt specific issues. See https://github.com/KDE/clazy for details and a list of the kind of warnings reported by clazy.

Environment

C++/Qt

Platform

Either QtCreator >= 4.6, standalone or upstream clang (note that xcode-clang and android-clang do not work)

Implementation effort

Very minimal (Qt Creator), small when already using upstream clang, potentially high if a project needs to be ported to upstream llvm/clang first.

Applicability

All projects using C++ Qt.

Caveats

  • Clazy implements several warnings levels. The higher levels can produce false positives.

See also

Implementation hints

Usage via Qt Creator is probably the easiest way to get started. Integration into a CI system is probably best done via the standalone version of clazy in combination with a compilation database.

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