Software developer stories
en de

Why I love the Qt framework

Everyone that knows me, knows that I love the Qt framework. Before I started programming in C++, Java was my primary programming language. I love the generics (yes, some of you will hate me for that opinion right now) and reflection. During my Java-time I used them very often to increase reusability. But while studying we had to learn C++ and I hated it in the beginning. It felt so old and so stiff compared to Java. But in one lecture we used Qt, and it was even more terrible - in the beginning. Signals, Slots, QWidgets, … it was too much. After working with it for some time it felt better. What I really liked about Qt from the beginning was the Qt Designer. For the first time I was able to have fancy ui’s in C++ and don’t have to bother with a C api. In Java, I had a graphical editor for Swing. So creating ui’s was now as easy as in Java, maybe a bit easier. But the results with Qt are much better and fancier. After some reading and experimentation I began to understand how Signals and Slots work. From now on I really liked Qt. It was awesome. It was so easy to accomplish tasks, and it still is. If you build an application with an ui and some heavy stuff to calculate, or simply said two threads to communicate, it is very easy with Qt. Just use Signals and Slots to communicate between the threads and the Qt framework will deal with all the synchronization stuff (If you use them properly). You can also use Signals and Slots to loosely couple objects. The sender-object that emitted the Signal, does not know where it is going and the receiver-object does not know where it came from. So you easily exchange components, just like with dependency injection. If I write an application and use the C++ standard library and Qt, I can be sure that it will compile and run on all the mayor platforms. A few months ago I switched from Windows to Linux. The reason why I did that can be found here Warum ich zu Linux wechsle if you can read German. I was so excited when I opened the project file of my Qt project. I developed the whole project in Windows and with a click of the “Compile & Run” button it was running under Linux. But the portability is not the only advantage. You have a huge Library with many classes solving different problems. If you want to use for example Network, no problem, just use it. The same goes for JSON support, XML, SQL, Bluetooth, OpenGL and many more. It’s just so convenient, you don’t have to search for a library, try to compile it and link it to your project, Qt does all that for you. So you don’t have to reinvent the wheel every time. At the beginning I mentioned reflection in Java. You can use reflection in Qt with the help of moc (Meta Object Compiler). So every class that inherits from QObject knows what class it is and other information at runtime.

The things I mentioned here are just a subset of what Qt is capable of. KDE is using Qt to build an entire desktop environment and other programs. And they are not the only ones using Qt, just have a look at the Wikipedia page of Qt and see companies like the European Space Agency, DreamWorks and Siemens.