GTK or Qt?

Submitted by peter on Mon, 05/28/2018 - 11:27

Qt and GTK are Graphical User Interface libraries used by software developers to add standard user interfaces to applications on Linux, Windows, and OSX. The reasons for choosing one are loosely based on fashion, practicality, and the details of the various releases of each library. There are also alternatives popping up faster than you can evaluate. There are good arguments for both.

Does it work?

GTK works for some things. Qt works for some things. In most cases they are similar and the differences depend only on the specific version. I found only one recent technical reason to choose either GUI library.

Qt does not work with the C programming language. To make Qt work with C, you have to put something else in the middle. The main reason for using C is speed and anything else in the middle slows down the C program. GTK works with C without anything in the middle. I was working on a C program so had to use GTK.

This is an example of where one of the GUIs, GTK or Qt, is an easier choice due to a clear cut technical difference. Most of the other technical differences only apply to specific versions or releases, making a technical comparison difficult.

Which uses the least memory?

There are plenty of people pushing Qt as using the least memory. I compared some Qt based applications with their GTK equivalents and the results were varied. The underlying applications varied in memory use more than the GUI components.

GTK supposedly uses more memory because GTK provides more functionality. Qt does less and uses less memory. If that is your logic, then you should also look at Aura and the many other user interface libraries providing less functionality.

GTK can be used at several levels. For example, you can start with the GTK application code or bypass that to work at a lower level. When you compare the alternatives, you get similar comparison problems. As an example, Aura can be used with or without a separate components named Ash.

In the small number of occasions, I created anything using GTK, I built up from the minimum, not down from the top. Memory usage was never a problem. From my experience, some GTK and many Qt applications are bloated compared to what they do.

KDE or Gnome?

KDE is a GUI layer for Linux and uses Qt. Gnome is a different GUI layer for Linux and uses GTK. Both went through multiple versions. Gnome is at version 3. KDE is at version 5.

I know people who love one and hate the other. I tried to use KDE a few times over and it failed each time. Gnome worked. It seems like a simple choice.

KDE fans are quick to tell me I should switch from Linux distribution A to B to get the best KDE experience. I have at times switched from A to B and still had problems. When I switch from A to B and mention the KDE problems in a KDE forum, the KDE fan reaction is often to tell me I should be using Linux distribution A, not B.

The differences between KDE and Gnome have little to do with either GTK or Qt. Qt applications work in Gnome and GTK applications work in KDE.

When I investigated the most bloated Qt applications, I found the bloat is because the applications include huge chunks of KDE that are unrelated to Qt. There are, sometimes, Qt based alternatives that are not KDE based and run without the bloat.

Google's contribution

Google decided Qt and GTK are both too heavy for Google's use. Google is currently pushing Aura with or without other helper libraries.

Users of Qt and GTK in application development both hoping their favourite library will be the first GUI to Android and set the standard. Google's actions with Aura killed that hope.

The most GTK or Qt can hope for is to be the first "cross platform" GUI to reach Android. At the rate Qt and GTK are progressing, it is more likely Aura will be ported back to Linux.

The next step might be to convert Qt and GTK to use Aura internally.

OSX

Some of the forums have GTK fans rubbishing Qt based on the problems in KDE. One classic remark was an OSX user complementing KDE by pointing out it is better than the OSX the user is forced to use at work. Based on the few occasions I was forced to use OSX and the many other operating systems Apple as dumped on users, OSX is more reliable than KDE. Working very slowly with OSX is better than not working at all with KDE.

An Apple fan retaliated by pointing out the "highlight" of OSX, the thing that is supposed to make OSX so much better than every other operating system. The fan pointed out what I found to be one of the worst parts of OSX, one of the biggest productivity killers. If I had a working KDE, I would test the KDE equivalent.

Some Qt fans point out that Qt based applications work on OSX as easily as on Linux or Windows while GTK is struggling outside of Linux. This is a strange because one of the most popular GTK based applications runs on OSX, Windows, and Linux.

Windows

Some Qt fans say most Qt use is on Windows. Their logic is simple, Windows developers use C++, not C, and Qt is written in C++, making the match ideal. They do not present statistics to prove their argument. Looking at the software flowing between Windows and other platforms, C, Java, and Python all appear to outweigh C++. Filezilla is an example.

In any case, most of the Linux/Windows cross platform programs were originally developed on Linux. Gimp is an example.

Documentation, examples, and tutorials

The current documentation for GTK is a messy mix of different releases and versions due to, in part, the GTK team making major changes to GTK in the middle of version 3. You have to select the right documentation version for your GTK library. Some versions are missing or very difficult to find.

I have not used Qt recently. Qt fans say Qt is stable within a version but they also complain about major incompatibilities from version to version. The documentation appears to be good within a version.

The main problem I find with GTK is the lack of usable examples. Their tutorials only show a narrow range of examples that were of little use for my recent very simple application. Their reference documentation does not show how you would use the code. They need something like the examples of use shown in the PHP reference documentation.

The limited GTK documentation added about twenty hours to the application development including time wasted using the GTK Application class. The class is recommended in the documentation but all the class did was add bloat and complexity. I wasted about six hours changing the application to add the class in then an hour to revert it back out.

Conclusion

Do not blame Qt or GTK for bloat in Gnome or KDE or any application. Both Qt and GTK can be used in bad code. Both may disappear under the flood of new GUI libraries.

Tags