Skip to content

QtDevelopment Get the RSS Feed

for feeds to planetqt and planetkde

clazy 1.2 released presenting 5 new Qt compile-time checks

In the previous episode we presented how to uncover 32 Qt best practices at compile time with clazy. Today it’s time to show 5 more and other new goodies present in the freshly released clazy v1.2.

New checks

1. connect-not-normalized

Warns when the content of SIGNAL(), SLOT(), Q_ARG() and Q_RETURN_ARG() is not normalized. Using normalized signatures allows to avoid unneeded memory allocations.


    // warning: Signature is not normalized. Use void mySlot(int) instead of void mySlot(const int) 

New in Qt 5.10: recursive filtering for QSortFilterProxyModel

When using Qt’s model/view framework, filtering has always been very easy with QSortFilterProxyModel. To filter a list using text typed by the user in a line-edit, you have certainly been applying the standard recipe:

  1. instantiate the proxy;
  2. insert it between view and source model;
  3. connect the lineedit’s textChanged signal to the proxy’s setFilterFixedString slot; done!

But what if the model is a tree rather than a flat list?

Let’s use the tree below as an example. As you can …

Un-deprecate your Qt project

The last post from my colleague Marc Mutz about deprecating Q_FOREACH caused quite an uproar amongst the Qt developers who follow this blog.

I personally feel that this was caused fundamentally by a perceived threat: there is a cost associated to porting away a codebase from a well-known construct (Q_FOREACH) to a new and yet-undiscovered construct (C++11’s range based for), especially when the advantages are not that clear. (With stronger advantages, maybe people would be more keen …

Writing Code That Won’t Kill A Functional Safety Source Book

Functional Safety is the term used for systems designed to minimize risk to human health. But there’s a dilemma in today’s tech-driven world.

We are more reliant than ever on software to control our planes, trains, cars, and boats, to operate our medical equipment, to process our food, to clean our water, and to power our homes. If these systems don’t function properly, they have the ability to injure, or even kill us. Meanwhile software complexity continues to increase exponentially …

Fixing bugs via lateral thinking

For today’s blog I would like to share with you the little adventure I had when fixing a very strange bug in Qt.

Pop quiz

Don’t think about this too much, just guess: what does this QML snippet print?

import QtQuick 2.0

QtObject {
    Component.onCompleted: {
        console.log("240000000000" == "3776798720");

There are no JavaScript semantic tricks involved; and using either == or === does not change the result in any way.

Did you get it?

Pop quiz (2)

Here’s …

Fuzzing Qt for fun and profit A brief introduction to fuzzing and how we successfully use it in Qt

Many KDAB engineers are part of the Qt Security Team. The purpose of this team is to get notified of security-related issues, and then decide the best course of action for the Qt project.

Most of the time, this implies identifying the problem, creating and submitting a patch through the usual Qt contribution process, waiting for it to be merged in all the relevant branches, and then releasing a notice to the users about the extent of the …

KDAB talks at QtCon 2016


This is a small wrap-up fromQtCon, the biggest Qt event in Europe in 2016, that happened at the beginning of September. At QtCon the Qt community joined forces with the KDE, FSFE and VideoLAN communities, to create an exciting event in the spirit of open collaboration and participation amongst projects.

During QtCon many KDAB engineers gave in-depth technical talks about Qt, QML, Qt3D, OpenGL and the other technologies around Qt development. All the sessions …

Goodbye, Q_FOREACH A Porting Guide to C++11 Ranged For-Loops

Q_FOREACH (or the alternative form, foreach) will be deprecated soon, probably in Qt 5.9. Starting with Qt 5.7, you can use the QT_NO_FOREACH define to make sure that your code does not depend on Q_FOREACH.

You may have wondered what all the fuss is about. Why is there a continuous stream of commits going to into Qt replacing Q_FOREACH with C++11 ranged for-loops? And why does it take so many commits and several Qt versions to port away …

Qt on Android: How to restart your application

Some time ago, I wrote a code to restart the running application on Android.

You might well ask why such a thing was needed. It was needed because there are cases where, whenever a user changes the theme, the application has to restart to apply the change (it can’t be applied on the fly). In my example I used it to restart Qt Quick Controls 2 gallery.

Sadly my fix was not accepted, because other platforms (iOS, IIRC) have this …

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.