Est. 2011


Integrating QML and Rust: Creating a QMetaObject at Compile Time

Posted by Olivier Goffart on 07 June 2018

In this blog post, I would like to present a research project I have been working on: Trying to use QML from Rust, and in general, using a C++ library from Rust.

The project is a Rust crate which allows to create QMetaObject at compile time from pure Rust code. It is available here:

Read more ...

Two C++ tricks used in Verdigris implementation

Posted by Olivier Goffart on 15 February 2018

I have just tagged the version 1.0 Verdigris. I am taking this opportunity to write an article about two C++ tricks used in its implementation.

Read more ...

QML vs. C++ for application startup time

Posted by Jocelyn Turcotte on 18 July 2017

After 5.8 reduced startup times with its QML compilation caching, object creation remains one of the largest startup time consumer for Qt Quick applications. One can use Loaders to avoid loading parts of the application that are not currently visible, but some scenes with higher complexity can still be taking quite some time to initialize when they urgently need to be displayed, especially on embedded systems.

At QtCon 2016 Andrew Knight presented a few benchmarks showing a situations where C++ can improve Qt Quick object creation times over QML. A conclusion of the session was that those benchmark results would need to be taken with a grain of salt since the specific benefits could be smaller in a real application relatively to everything else happening around.

What we’re presenting today are results of converting parts of a well-known QML example to C++ using public and private APIs, measuring the improvements on loading and execution times to have a better estimate of the opportunity for real world applications.

Read more ...

Woboq Code Browser: under the hood

Posted by Olivier Goffart on 24 October 2016

A few years ago, I was introducing the code browser and

Since the then, we implemented a few new features and made the source code available, which you can browse from the code browser itself.

In this article, I give more technical information on how this is all done.

Read more ...

QReadWriteLock gets faster in Qt 5.7

Posted by Olivier Goffart on 10 August 2016

In Qt 5.0 already, QMutex got revamped to be fast. In the non contended case, locking and unlocking is basically only a simple atomic instruction and it does not allocate memory making it really light. QReadWriteLock however did not get the same optimizations. Now in Qt 5.7, it gets on par with QMutex.

Read more ...

QIcon::fromTheme uses GTK+'s icon cache in Qt 5.7

Posted by Olivier Goffart on 16 June 2016

When you pass a name to QIcon::fromTheme , Qt needs to look up in the different folders in order to know which theme contains the given icon and at which size. This might mean a lot disk access needs to be done only in order to find out if the file exists. Applications such as KMail can have hundreds of icons for each of their menu actions.
In the KF5 port of KMail, 30% of its start-up time was spent loading those icons.

With Qt 5.7, the GTK+ icon cache will be used to speedup the loading of icons.

Read more ...

Verdigris: Qt without moc

Posted by Olivier Goffart on 25 May 2016

Verdigris is a header-only library that can be used with Qt. It uses macros to create a QMetaObject that is binary compatible with Qt's own QMetaObject without requiring moc. In other words, you can use Verdigris macros in your Qt or QML application instead of some of the Qt macros and then you do not need to run moc.

Read more ...

Moc myths debunked

Posted by Olivier Goffart on 22 February 2016

I have often read, on various places, criticisms about Qt because of its use of moc. As the maintainer of moc I thought it would be good to write an article debunking some of the myths.

Read more ...

How Qt Signals and Slots Work - Part 3 - Queued and Inter Thread Connections

Posted by Olivier Goffart on 04 February 2016

This blog is part of a series of blogs explaining the internals of signals and slots.

Read more ...

QDockWidget improvements in Qt 5.6

Posted by Olivier Goffart on 18 December 2015

We made some improvements to QDockWidget for Qt 5.6. You can now re-order your QDockWidget's tabs with the mouse. There is also a new mode you can set on your QMainWindow so that you can drag and drop full groups of tabbed QDockWidgets. Furthermore there is a new API which allows you to programatically resize the QDockWidgets.

Read more ...

New in Qt 5.5: Q_ENUM and the C++ tricks behind it

Posted by Olivier Goffart on 02 July 2015

Qt 5.5 was just released and with it comes a new Q_ENUM macro, a better alternative to the now deprecated Q_ENUMS (with S).

In this blog post, I will discuss this new Qt 5.5 feature; What it does, and how I implemented it. If you are not interested by the implementation details, skip to the conclusion to see what you can do in Qt 5.5 with Q_ENUM.

Read more ...

GPU drawing using ShaderEffects in QtQuick

Posted by Jocelyn Turcotte on 11 May 2015

A ShaderEffect is a QML item that takes a GLSL shader program allowing applications to render using the GPU directly. Using only property values as input as with the Canvas in our previous article, we will show how a ShaderEffect can be used to generate a different kind visual content, with even better performances. We will also see how we can use the fluidity it provides in user interface designs, again taking Google's Material Design as a concrete example.

Read more ...

Smooth animations using the QtQuick Canvas

Posted by Jocelyn Turcotte on 04 May 2015

Google's Material Design showcases a few nicely detailed animations that add life to the user interface. QML makes it straightforward to create the traditional moving, scaling and opacity change animations while taking advantage of the GPU, but how can we create an animation changing the shape of an element and not merely transforming it?

Today we'll see how we can use the QML Canvas item to create an animated simplified version of the Android's drawer and back arrow button.

We'll make sure that we use the GPU to accelerate the rendering and use standard QtQuick animations to control the drawing evolution, as conveniently as with traditional transform animations.

Since you can animate any property in QML, not only the built-in ones, you can define the animation parameters declaratively as properties and then use those as input for your JavaScript Canvas drawing code, requesting a repaint each time an input changes.

Read more ...

QMetaType knows your types

Posted by Olivier Goffart on 22 April 2015

QMetaType is Qt's way to have run-time dynamic information about your types. It enables things such as QVariant wrapping of custom types, copy of queued connection arguments, and more.

If you ever wondered what does Q_DECLARE_META_TYPE or qRegisterMetaType do and when to use (or not to use) them, read on. This article will describe what you need to know about QMetaType: What is its purpose; How to use it; And how it works.

Read more ...

Nicer debug output in Qt using QT_MESSAGE_PATTERN

Posted by Olivier Goffart on 19 February 2015

If you are using Qt, you might have some qDebug or qWarning statements in your code. But did you know that you can greatly improve the output of those with the QT_MESSAGE_PATTERN environment variable? This blog post will give you some hints and examples of what you can do.

Read more ...

C++14 for Qt programmers

Posted by Olivier Goffart on 17 November 2014

C++14 is the name of the version of the standard to be released this year. While C++11 has brought many more feature that took time to be implemented by the compilers, C++14 is a much lighter change that is already implemented by compilers such as clang or gcc.

Qt 5 already was adapted in many ways so you can make use of the new features of C++11. You can read about that in my previous article. C++11 in Qt5 . This article mention some of the changes in C++14 and the impact on Qt users.

Read more ...

QWaitCondition: Solving the Unavoidable Race

Posted by Olivier Goffart on 05 August 2014

This is the story how I have (not) solved a race condition that impacts QWaitCondition and is also present on every other condition variable implementations (pthread, boost, std::condition_variable).

bool QWaitCondition::wait(int timeout) is supposed to return true if the condition variable was met and false if it timed out. The race is that it may return false (for timeout) even if it was actually woken up.

The problem was already reported in 2012. But I only came to look at it when David Faure was trying to fix another bug in QThreadPool that was caused by this race.

Read more ...

Can Qt's moc be replaced by C++ reflection?

Posted by Olivier Goffart on 11 March 2014

The Qt toolkit has often been criticized for extending C++ and requiring a non-standard code generator (moc) to provide introspection.
Now, the C++ standardization committee is looking at how to extend C++ with introspection and reflection. As the current maintainer of Qt's moc I thought I could write a bit about the need of Qt, and even experiment a bit.

In this blog post, I will comment on the current proposal draft, and try to analyze what one would need to be able to get rid of moc.

Read more ...

Saving Disk Space on your Linux Server with Squashfs

Posted by Markus Goetz on 28 January 2014

We have been running our browsable code repository for quite a while now. Adding more and more projects, at some point we noticed that we were getting low on disk space. In this blog post, we explain how we saved huge amount of disk space holding our static HTML files.

Read more ...

Objective C (iOS) for Qt C++ Developers

Posted by Markus Goetz on 20 August 2013

For our first customer iOS application, I had to learn Objective C. Coming from the Qt world that was not too hard. To make life even easier for the readers of this blog, I am going to describe some of the things I have learnt. This is more of a brain dump than a tutorial, but I still hope it is useful for you.
I'll first write about the language differences and then about the class libraries.

Read more ...

Profiling PHP Applications with XDebug (using ownCloud as an Example)

Posted by Markus Goetz on 15 August 2013

XDebug for PHP is a PHP extension that enables you (amongst other things) to create (KCachegrind compatible) profiling files. I'm showing here how we can use those to analyze ownCloud's performance.

Read more ...

Proof Of Concept: Re-implementing Qt moc using libclang

Posted by Olivier Goffart on 10 June 2013

I have been trying to re-write Qt's moc using libclang from the LLVM project.

The result is moc-ng. It is really two different things:

  1. A plugin for clang to be used when compiling your code with clang;
  2. and an executable that can be used as a drop in replacement for moc.

Read more ...

Data initialization in C++

Posted by Olivier Goffart on 16 May 2013

In this blog post, I am going to review the different kind of data and how they are initialized in a program.

Read more ...

Property Bindings and Declarative Syntax in C++

Posted by Olivier Goffart on 28 February 2013

QtQuick and QML form a really nice language to develop user interfaces. The QML Bindings are very productive and convenient. The declarative syntax is really a pleasure to work with.
Would it be possible to do the same in C++? In this blog post, I will show a working implementation of property bindings in pure C++.

Disclaimer: This was done for the fun of it and is not made for production.

Read more ...

iQuassel for iPhone and iPod

Posted by Markus Goetz on 25 February 2013

In our spare time at Woboq, we also do projects that scratch our own itches. For Olivier this was his web-based source code browser, for me it was my Quassel IRC client for iPad.

Read more ...

QMap vs. QHash: A small benchmark

Posted by Olivier Goffart on 19 February 2013

While working on my Qt developer days 2012 presentation (QtCore in depth), I made a benchmark comparing QMap and QHash. I thought it would be nice to share the results in this short blog entry.

Read more ...

QThread: You were not doing so wrong.

Posted by Olivier Goffart on 22 January 2013

This post is about the use of QThread. It is an answer to a three years old blog post by Brad, my colleague at the time:
You're doing it wrong

Read more ...

How Qt Signals and Slots Work - Part 2 - Qt5 New Syntax

Posted by Olivier Goffart on 17 December 2012

This is the sequel of my previous article explaining the implementation details of the signals and slots. In the Part 1, we have seen the general principle and how it works with the old syntax. In this blog post, we will see the implementation details behind the new function pointer based syntax in Qt5.

Read more ...

How Qt Signals and Slots Work

Posted by Olivier Goffart on 02 December 2012

Qt is well known for its signals and slots mechanism. But how does it work? In this blog post, we will explore the internals of QObject and QMetaObject and discover how signals and slot work under the hood.

In this blog article, I show portions of Qt5 code, sometimes edited for formatting and brevity.

Read more ...

Browsing C++ Source Code on the Web

Posted by Olivier Goffart on 18 September 2012

As a developer, I write code, but I also read a lot of code. Often the code of other people. It is easy to get lost among all the functions, objects or files. What calls what? What does this function exactly do? Where is this variable modified? It is important that as much information as possible can be presented or easily accessible.

Good IDEs are good at displaying that information and ease the navigation in the source code. But often, I want to browse source code which I don't necessarily have on my hard drive. While I look at code on the web, I am very disturbed by the poor browsing experience. This is why I developed an online code browser.

Read more ...

UTF-8 processing using SIMD (SSE4)

Posted by Olivier Goffart on 26 July 2012

SIMD: "Single instruction, multiple data" is a class of instructions present in many CPUs today. For example, on the Intel CPU they are known under the SSE acronym. Those instructions enable more parallelism by operating simultaneously on multiple data.

In this blog post I will present a method for converting UTF-8 text to UTF-16 using SSE4 compiler intrinsics. My goal is also to introduce you to the SIMD intrinsics, if you are not familiar with them yet.

Read more ...

We are now offering Quassel IRC Hosting

Posted by Markus Goetz on 07 July 2012

In an attempt to bring the things we like to you, we are offering accounts on our Woboq Quasselcore.

Read more ...

C++11 in Qt5

Posted by Olivier Goffart on 11 June 2012

C++11 is the name of the current version of the C++ standard, which brings many new features to the language.

Qt 4.8 was the first version of Qt that started to make use of some of the new C++11 features in its API. I wrote a blog post about C++11 in Qt 4.8 before the 4.8 release which I won't repeat here.

In Qt5, we make use of even more features. I will go into detail about some of them in this post.

Read more ...

QStringLiteral explained

Posted by Olivier Goffart on 21 May 2012

QStringLiteral is a new macro introduced in Qt 5 to create QString from string literals. (String literals are strings inside "" included in the source code). In this blog post, I explain its inner working and implementation.

Read more ...

Signals and Slots in Qt5

Posted by Olivier Goffart on 12 April 2012

Qt5 alpha has been released. One of the features which I have been working on is a new syntax for signals and slot. This blog entry will present it.

Read more ...

On Reviewing a Patch in Qt

Posted by Olivier Goffart on 23 January 2012

While I was working on Qt at Nokia I spent a lot of time reviewing patches from colleagues.

Peer reviewing is an important step, and there is a reason why we do it in Qt.
Code in libraries (such as Qt) requires much greater care than application code.
The main reason is that you need to maintain compatibility for your users. You want to avoid regressions in your library, so code that works continues to work, even if the user did some hack or trick. For the user of the library, it has great value to be able to upgrade it without too much effort. A subtle behaviour difference in the library might introduce a bug in the application that might be really hard to track in the millions of old lines of code of the application.

Read more ...

Internals of QMutex in Qt 5

Posted by Olivier Goffart on 21 December 2011

You may want to read this blog if you want to understand the internals of QMutex or if you are interested in lock-free algorithms and want to discover one. You do not need to read or understand this article if you just want to use QMutex in your application. I found implementing QMutex interesting and therefore I want to share the knowledge.

I am going to show and explain a simplified version of the real code. If you want to see the real code, you can just browse the Qt source code. This article will help you to understand the concepts.

Read more ...

Introduction to Lock-free Programming with C++ and Qt

Posted by Olivier Goffart on 13 December 2011

This blog post is an introduction to lock-free programming. I'm writing this because this is the pre-requisite to understand my next post. This was also the content of my presentation for Qt Developer Days 2011.

Lock-free programming is the design of algorithms and data structures that do not acquire locks or mutexes.

Read more ...

© 2011-2023 Woboq GmbH
Google Analytics Tracking Opt-Out