Tag Archives: C++

Qt’s style system FTW (Adding Theme Support to a Qt Application)

A few years ago, I was asked to add a “theme” to a Qt project of mine. I wasn’t fully aware of the power of Qt’s style system, so I did it the hard way. I created a configuration file that contained the theme-able attributes of just about everything I could think of. And when the application started, I parsed it and applied the colors, fonts, etc. After a short bit, I noticed things I had overlooked and added them. It wasn’t amazingly hard, but it sure could have been easier. Today I’d like to discuss the easy way :-).

Read More...

(Not so much) Fun with QSharedPointer

Qt has a wonderful way of dealing with memory management. The core idea is simple. Most objects have a parent, and when the parent gets destroyed, it will first destroy all its children. Using this technique, you can often write your Qt applications with little to no concern for memory management. Often, you literally don’t have to have a single delete in your entire application. That’s pretty sweet!

In addition, since Qt 4.5 QSharedPointer was introduced, which is very similar in concept to boost::shared_ptr (and thus std::tr1::shared_ptr). I have long been a huge fan of the idea of smart pointers. They solve the need to worry about memory management for almost all usual cases. Unfortunately, when you combine these two concepts, sometimes you can go awry. I was surprised by this one, so I figured I’d share my findings :-).

Read More...

Combining Qt’s Signals and Slots with c++0x lamdas

Qt is a fantastically designed library. However, every now and then I think of something that I wish they offered that they don’t. It’s almost always something small and easily worked around, but it would be nice if it were just there. This time around, that feature is the ability to connect a signal to a function that is not a member of a class/struct. Specifically, I think it would be really cool if I could connect it to a c++0x lambda! Especially now that the [ISO C++ committee approved the C++0x final draft][1].

Read More...

How not to handle a bug report

I recently submitted a bug report to Qt software, the results were less than impressive. One thing I’d like to make clear though is that Qt is an amazing library that I would recommend to any c++ software developer, I truly mean that. It is well designed, well documented, and generally works as advertised. On top of all of this, it is portable! It really just gets better and better. This is why I found the handling of my bug report so… underwhelming.

Read More...

How not to maintain an API

So I’ve been working on my graphing code for EDB. I was eventually able to create a Qt widget that natively renders a graphviz graph layout. It actually works quite nicely, you can create an ordinary Graphviz graph either in memory or from a file like usual. The code can simply create a “GraphWidget” and the code will display the graph perfectly (there are some constructs that it doesn’t support, but the basics are there) with nice things such as zooming and rotating.

All of this works great, except for the fact that Graphviz decided to change some of the structures used to represent the laid-out graph.

Read More...