When, where and why to use Qt?

Author: Ender EREL, Expert Software Engineer – Embedded Systems

 

Qt is a modular, cross-platform application development toolkit for C++. It was first released in 1995 [1], and has gained widespread use since then. The biggest misconception about Qt is that it is considered to be a GUI library. Even though this is partially correct, Qt is much more than that. Qt not only contains a GUI module, but also a wide selection of modules to make application development and deployment faster and easier on projects of all scales. Cross-platform modules exist for GUI, network, threading, multimedia, scripting, 3D, web, xml and more [2]. In addition to these, Qt also contains platform-specific modules where applicable, e.g positioning, sensors, NFC [2]. This modularity allows Qt to be tailored specific to each project’s needs. Another part of the toolkit is QtCreator, an integrated development environment specifically created for making development with Qt easier and faster.

Another advantage of Qt is its flexible licensing options. Even though it has been proprietary in the past, it was later also offered as GPL licensed software [3]. The main reason behind this is that Qt is a major component in KDE and a foundation has been formed to ensure that Qt will always have an open source licensing option in the future. With the Qt 4.5 version released in 2009, LGPL was added to available licenses, which in turn enabled commercial or proprietary software to use Qt. [3]

The biggest advantage of Qt is its proficiency in providing portability. This has led to a fast expansion of its user base in its early days, which in turn has created a very large community and a big advantage over its competitors. The google search trends [4] show that Qt has been in the lead for some time, and the gap between its closest competitors has widened over the past 10 years, as seen in Graph 1.

Graph 1: Google Trends for Qt and its competitors between 2007-2016 [4]

Another indicator of the size of the community can be inferred by the popular site StackOverflow. SO currently has 56000+ questions tagged with ‘Qt’ label. For comparison GTK+ has 5900+ and wxWidgets has 2500+ questions [5]. The distribution of these labels also show that Qt has been widening its user base since 2008, as seen in Graph 2.

 

Graph 2: StackOverflow tag trends between 2008 – 2016 [5]

However, there are two properties of Qt that has been the subjects of discussions over the years. The first one is its usage of a pre-processing step called the “Meta Object Compiler”. It has sometimes been described as not standard C++, but this is a misunderstanding. What MOC does is parsing the header files for some predefined macros and generating C++ code to support features like signal/slots, introspection and property system [6]. Even though the “not standard C++” misconception is false, it is true that Qt requires an additional step in the build system.

The second debate point has been the size of Qt’s resource needs, which tend to be rather large. It has larger memory footprint than competitors and when all the library is compiled, it can reach sizes that can be considered too much for platforms with limited space. But this is somewhat rectified by Qt’s modularity, which has been improved in Qt 5, so projects can choose to include modules as they require. Further reductions can be done by removing unneeded features via several configuration switches. Therefore it can be argued that Qt may not be the best choice for targets with extremely limited capabilities.

Despite the mentioned debatable weaknesses, its advantages have contributed to the success of Qt and this popularity has kept Qt development active for 20 years. As a result, Qt has become a very strong, almost unparalleled toolkit for application development in C++ (and several other via language bindings) and trends show that it will continue to be around for years to come. This makes Qt a strong candidate for new projects of medium to large sizes and all variations, as demonstrated by the examples from automotive, entertainment, automation, medical and other industries. [6]

References:

[1] http://my.safaribooksonline.com/0131872494/pref04

[2] http://doc.qt.io/qt-5/qtmodules.html

[3] https://en.wikipedia.org/wiki/Qt_(software)#Becoming_Free_Software-friendly

[4] https://www.google.com/trends/explore?date=2007-01-25%202017-01-25&q=%2Fm%2F069fr,wxwidgets,%2Fm%2F0chq_

[5] http://hewgill.com/~greg/stackoverflow/stack_overflow/tags/#!qt+gtk+wxwidgets

[6] https://www.qt.io/built-with-qt/

[7] http://doc.qt.io/qt-5/why-moc.html

[8] http://www.kdab.com/qt-android-episode-4/

Leave a Reply

Your email address will not be published.