Styles in Qt and KDE: A new approach

Speaker: Eduardo Madeira Fleury

The current QStyle API and by consequence KStyle, has been around for quite some time. While it has provided good services, it is getting somewhat outdated. Technologies like QGV, QtQuick and future canvasses require more than it can offer. Thinking about that, we at openBossa have been working together with Marius Bugge Monsen, from QtDF, on a proof of concept for what could be the next generation of Qt's styling system.

The proposed solution provides a way of styling widgets by declaring a primitive-tree for each one rather than using the current procedural painting. That allows styles to be more different from each other and also the caching of painted widgets becomes easier as well as benefits the coding of native-looking styles.

Another potential benefit of the new system is the way it moves data between the styled widgets and the primitives used to draw it. Older systems rely on the widget passing data structures (StyleOption) to the style so it can update the primitives, we understand that to be clumsy. So we brought the QtQuick data binding concept to C++, which we understand to be more elegant.

Finally, that solution does not depend on a specific technology (QWidget, QGraphicsWidget or QDeclarativeItem). That means it can be used for any of these or upcoming ones, with little effort.

Furthermore, we did some experimentation on the idea of using hybrid solutions. For instance, a C++ application could have its widgets styled by an UI designer using only QtQuick, and no C++. The proof of concept is functional and we had a good experience writing those styles when compared to the effort it would require to do the same using current styling in procedural C++.

So in this talk I would like to expose the shortcomings of the current system, go into details about the benefits of the proposed solution, show demos and examples of what we did, and bring up the discussion on whether that makes sense for the KDE community. Chances are that this will pave the way for the next upstream styling system in Qt. The timing for this year's Akademy is great for KDE to influence that design.

Eduardo Madeira Fleury

Eduardo Madeira Fleury graduated in Computer Engineering at Unicamp (Brazil), has been using GNU/Linux since 1998 when Connectiva Guarani was released. Loves to map and solve problems, as well as to spend some time by the northeastern Brazilian beaches. Has worked for IBM's Linux Technology Center and has been developing Qt at openBossa/INdT where took part of the creation of QGraphicsAnchorLayout and experimented with layout animation, Qt Quick and next generation widgets and styling.