DEV Community

Cover image for [Qt] I. Why you should learn Qt
Misinahaiya
Misinahaiya

Posted on • Edited on

[Qt] I. Why you should learn Qt

"The future is written with Qt."

Qt Group

There is a general rule of software design, irrespective of where you are; regardless of the type of software you are crafting: I generally do not consider any frameworks or libraries will survive under the overly keen competitions among different tools in assisting the overall application design, nor any additional libraries that are not endorsed by the tech giants or the standards.

Yet, Qt is obviously the exception - the extraordinary exception that will not perish in time. Ever.

Released back in 1995, Qt continuously showed its unparalleled talents in producing either small-scale toy applications, as well as the heavy and strong titans. From time to time, software of various types and functions may disappear from the shelves, and be forgotten by the end users who soon have found better alternatives. When, in the next time, you surf the Internet or especially the Application Store, do remember peek that whether the things you installed on your computer a decade ago is still here. I could guarantee that over 75% will be gone without leaving a word nor reason.

Undoubtedly, the ever-increasing demand from the market and the overly keen competition contribute significant reasons for software, tools and all sort of things being gone, which - the latter ones - were once all the rage. But, what's more, there are some reasons also contribute as significantly as the external factors:

What Are the Advantages of Qt?

So, what reasons brought the perished apps or packages down? Or, in other words, what made Qt flourish? Let us investigate.

First, it's cross-platform

Yep, you're right. Stepping into the mobile era could we hardly recognize that how hard it is for cross-platform compatibility. In the bygone, dark days of computers of the 1980's to 1990's, where a single operation of "one-plus-one" took years and a laptop looked like a printer, every single piece of code was basically invalid on another machine, even it could be compiled successfully on one.

As of then, computer scientists struggled. Why? It is just simply because that they could not find a stable solution of stable building and stably deploy the stable code. They were seeking their utopia of "Write Once, Build Everywhere".

"Will these come true?" Unfortunately no, at least in the 80's, as in the mid-1980's making an cross-platform solution was far-fetched as there were not any standardized descriptions of how computers execute code via their chips and CPU's. For example, assume that an Intel CPU port 0xE which served for Microsoft DOS or Windows might be responsible for jumping, but an ARM chip will just be on strike.

But things have to go on. A cross-platform solution must be presented. Then, many firms had decided to make some protocols and all sort of fancy things to make cross-platform possible for the major programming languages like C/C++, Java or Python. As intended, the pursuit of cross-platform software successfully filtered a considerable portion of old and unstable pieces of software.

So, why are the protocols and the cross-platform compatibility related to Qt? Well, as you might have already guessed, Qt is an extremely powerful library in terms of cross-platform compatibility. Basically, without any modification could your code be compiled on every platform as long as Qt itself supports so, given that you have not used any external or 3rd-party libraries.

This already filtered out the some potential alternatives like Windows UI or Cocoa. Might you ask, what about Python's Tkinter or C++'s WxWidgets? Aren't they also cross-platform solutions?

Second, it's feature-rich

To measure how mature (or good, whatever) a library is, the metrics we should be using is not quite the cost (let alone being open-source or the license used under), nor the community engagement. These are not that important as the metric: features. How many classes or namespaces of different genres the library has? How many languages does it support (or, how is the internationalization going)? How, or if it is, possible to implement both simple apps like a Notepad or complex apps like GIMP?

It is, undoubtedly, filtered out another good portion of the potential alternatives of developing applications.

I have used almost all the major application development frameworks, including Python's Tkinter (and some of its derivatives), C++'s Qt and WxWidgets, as well as Java's Swing. All of them are not that holistic enough. How? Why?

A picture is worth a thousand words. Look at the Qt classes:

Things with Qt

These are not the screens of the crackers used in films. These are the synopsis of all the Qt classes. Not only GUI design, but Qt is able and mighty to deal with networking (Qt Network), code editing (Scintilla), communicating with D-Bus (Qt D-Bus) on Embedded or ActiveX servers on Windows (Qt ActiveX), unit testing (Qt Test), doing Bluetooth (Qt Bluetooth), charting (Qt Chart and Qt Data Visualization) and XML (Qt XML), authorizing using Open-authorization (Qt OAuth), doing with SQL (Qt SQL) or serial ports (Qt Serial Port), and making web applications or browsers (Qt Web Channel, Qt Web Socket, Qt Web Engine and Qt Web Engine Widgets). Want to play music or video? Even better, record one? Use Qt Multimedia with Qt Multimedia Widget! Want to make your own 3D Google Map or Google Earth with JavaScript? Use the Qt Quick (3D) of the Qt QML (Qt's own programming language) with Qt Location! The list goes on and cannot reach an end.

How to prove so? Look at the big players in software design:

  • Adobe's Photoshop Element uses Qt.
  • Google's Google Earth uses Qt.
  • TeamViewer uses Qt.
  • Telegram uses Qt.
  • VideoLAN's VLC Player uses Qt.
  • Oracle's Virtual Box uses Qt.
  • Dreamworks Pictures uses Qt.
  • Disney's animations use Qt.
  • Chinese office, the WPS Office, uses Qt.

Again, the list goes on and cannot reach an end.

"Okay, I admit that Qt is powerful. But this does not prove the other cross-platform frameworks and persuades me to learn Qt." Yep, how about WxWidgets or Swing, which was once favored, or Tkinter? Well, they are, in the contrary, not that feature rich. An example: you cannot paint widgets freely in WxWidgets or Swing as it does not provide any good interfaces for the program to customize the widgets and regions (ah yes, customization should be an important feature). In Tkinter it's crazier and more nonsense: it does not even provide any ways for the program to paint their widgets.

A more subtle example: you have all encountered the "Justify" option in Microsoft Word or LibreOffice Writer, right? So you could expect that every GUI library has an option on its rich-text editor: justify. Disappointingly, neither WxWidgets nor Swing nor Tkinter implement so. Only Qt, which is almost almighty in every aspect of application development could do so. Furthermore, you could launch an HTML file in rich editing (yep, besides normal web browsing) with a bit limited support. Frankly, I haven't encounter any frameworks with this level of meticulous design.

You Couldn't Say Qt Is Flawless

I do admit that Qt is not flawless, as any other thing in the word does.

It's devilishly hard!

Qt does, indeed, have a steep learning curve. You should get to know the basics before you get on to craft any projects - this rules is applied everywhere, for every tools it is the general rule. However, in Qt, the "basics" should be defined as the "advanced pattern" in other tools. Setting up a project might include necessary knowledge on CMake or QMake (either one used for the build system), QObject and QApplication, as well as the model/ view structure and the basic uses of each widget.

But fear not! For in this series I am going to help all of you. From as simple as the basic moves like creating a QApplication instance, to the most advanced moves like crafting a LibreOffice Writer-like application as the hands-on projects, I am going to explain every detail that matters as I might. The key is, to have a committed heart in learning Qt and to try to do everything as you might, and enjoy your learning process. That was also my key believes in learning Qt.

I don't have a buck!

Regarding to the cost, Qt (and almost all of its derivatives) has a dual-license system. To explain, if you sell your application (or make any profit from your application) developed by Qt, you have to pay Qt an amount of money calculated from the profit you have gained. Someone groaned that the system is expensive and unfair, as they have only seen the expensive Enterprise solutions. Indeed, they are expensive. They just mainly provide supports for the non-developers in the company for those which have already written on the documentation. So, we, as developers, do not really need these kinds of services like instructive or installations.

They did not also consider that if you did not earn any profit from your applications, you do not need to pay Qt as it uses the LGPL license, which enables you to use the software freely under certain conditions. Qt is fair, if you do not let others pay a buck, you do not need to pay a buck.

In A Nutshell...

All these point to that broad and open road, where both firms like Google and Oracle, and individuals meet and are more crowded than the Times Square in New York. The road is called, "Go Learn Qt".

Editor Sample

This editor is built entirely with Qt and C++. Do you want to have one? Stay tuned to this series and wait till the end, where I will teach you how to build an editor like this, an editor like Microsoft Word and many more.

Top comments (0)