Continuing the series on KDAB contributions to Qt 5.0 (part 4), this time we cover community involvement, work on the Qt installer, QPointer and QWeakPointer modernization, and various macros.
KDAB has been contributing to Qt since before the launch of Open Governance. With the launch of the Qt Project, everything changed regarding how Qt is made.
- All development and design discussions became ‘open’
- All who contribute to Qt started to do so as equals
- All who depend on Qt became able to use their time and money to directly influence the progress of Qt.
KDAB community involvement ranges from development, code design and reviews to community support such as IRC chat, mailing lists, and Qt Project forums where KDABians Sean Harmer and Giuseppe D’Angelo are moderators.
- QtWidgets module – Marc Mutz
- Itemmodel and Itemviews – Stephen Kelly
- QMimeType support – David Faure
For Qt 5.1, KDAB is additionally assuming maintainership of the Qt3D and QtX11Extras modules.
Maintainership in Qt 5 is about ensuring that the code is always ready to enter a release cycle, and ensuring that all code submissions get reviewed, so this is certainly part of ‘making the release happen’.
One of the highlights of the Qt calendar for several years has been the Qt Developer Days. KDAB organized the European Qt Developer Days event in 2012 together with co-hosts ICS and Digia, and partner organization KDE. The event was a huge success, taking place in Berlin and featuring expert Qt training, a wide range of talks and speakers from throughout the industry, and plenty of social events. KDAB also co-hosted the sibling Developer Days event in Silicon Valley. Both events coincided closely with release candidates for the eventual Qt 5.0.0 release.
Tracking QObjects with QPointer
Various work went into QPointer and QWeakPointer in Qt 5.0. Although QPointer was mostly replaced in Qt 4, after some back and forth, it eventually became again the preferred smart pointer to use to track QObjects. The previous preferred method of tracking QObjects was deprecated by myself.
Marc Mutz also optimized the implementation of QPointer in several ways. One of the optimizations is a code-size optimization. QPointer had been refactored to be re-implemented in terms of QWeakPointer – because QWeakPointer is already the more-performant and because one implementation is better than two. The problem with the initial implementation was that QPointer<T> was implemented in terms of QWeakPointer<T>. That means that any time a QPointer is instantiated with a new type, the compiler needs to create lots of duplicate code for each type.
This problem is known as template bloat. The solution was to implement QPointer<T> in terms of QWeakPointer<QObject>. Because QPointer has only ever worked with subclasses of QObjects, it was possible to avoid template bloat by using casting, and remain source-compatible.
Many more macros
If debugging code, writing Squish GUI tests, or marking objects to more-easily find them in tooling, giving QObjects an objectName is a common task. For any task which is so common, a convenient and fail-safe way to execute it is always welcome.
In this case, KDAB added the Q_SET_OBJECT_NAME macro to Qt, which is always available. It can be used with QObjects as pointers or as values:
QWidget *smartWidget = new QWidget;
Another macro added for Qt 5 is the QT_NO_SIGNALS_SLOTS_KEYWORDS macro.
Defining that macro while using Qt disables the Qt keywords ‘signals’ and ‘slots’, forcing the user to use the alternative keywords ‘Q_SIGNALS’ and ‘Q_SLOTS’ instead. This is desirable when using boost, which uses ‘signals’ itself, and when using some Mac headers which use ‘slots’. The Qt 4 solution for this is the QT_NO_KEYWORDS define, but that also makes it impossible to use ’emit’, forcing users to use ‘Q_EMIT’. The new macro is a ‘smaller hammer’ to solve the smaller problem. The QT_NO_KEYWORDS macro also still exists of course.