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: https://github.com/woboq/qmetaobject-rs
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.
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.
Posted by Olivier Goffart on 24 October 2016
In this article, I give more technical information on how this is all done.
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.
Posted by Olivier Goffart on 16 June 2016
When you pass a name to
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.
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.
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.
Posted by Olivier Goffart on 04 February 2016
This blog is part of a series of blogs explaining the internals of signals and slots.
- Part 1 - How Qt Signals and Slots Work
- Part 2 - Qt 5 new syntax
- Interlude - QMetatype knows your types
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.
Posted by Olivier Goffart on 02 July 2015
Qt 5.5 was just released and with it comes a new
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
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.
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?
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.
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
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.
Posted by Olivier Goffart on 19 February 2015
If you are using Qt, you might have some
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.
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.
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.
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.
Posted by Markus Goetz on 28 January 2014
We have been running our browsable code repository code.woboq.org 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.
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.
Posted by Markus Goetz on 15 August 2013
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:
- A plugin for clang to be used when compiling your code with clang;
- and an executable that can be used as a drop in replacement for moc.
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.
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.
Posted by Markus Goetz on 25 February 2013
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Google Analytics Tracking Opt-Out