Learn C++, Qt, and QML the easy way

Bryan Cairns (VoidRealms)
6 min readFeb 23, 2021

--

Qt is a cross-platform set of libraries written in C++ that let you develop applications that run virtually anywhere, compiled to native code with blistering fast graphics. Their slogan is write once, build anywhere.

All with the same code base!

I hate math…

The first C++ book I bought was written by a mathematician who wanted to teach you C++ by using lot and lots of math. I equated C++ to math, and that it instantly made me flee back to other languages. I threw the book in the trash and did not think about C++ again for years.

When I first looked for a cross-platform development solution, I will admit the last thing I thought of was C++. It was old, had a steep learning curve and to be brutally honest I could not wrap my head around it. All the documentation I found was outdated or did not work on my system. I want to be productive today, before I go to lunch…not 6 months from now.

I had a project that needed to be cross-platform, interface with hardware, compile to native code, and nothing out there came close to the other list of requirements.

Then Qt came along

Standing in a book store, I glanced on this book…

Thumbing through it, while holding a cup of hot chocolate, I noticed

— it made sense to me —

Qt seemed to do the impossible in my brain. C++ was not hardcore math, or deep diving into system APIs and learning obscure code that never compiled. I bought the book and spent the next week devouring it. A few minor things did not work, but most, just worked flawlessly. On top of that I started finding other people that seemed eager to help. I was determined to learn it, and master it if possible.

Write once and build anywhere was the Qt motto…the same code you write on windows could be compiled and run on linux. And Qt (while not perfect) solved most of the development challenges with little effort.

But Qt was also evolving at a fast pace.

It runs on just about anything — from desktops, laptops, servers, smartphones, iphones, android, embedded devices, car dashboards and just about anything imaginable.

Unlike other frameworks, Qt continually builds on itself, backwards compatibility has been a huge blessing.

Experience is the best teacher.

I had to learn a lot about C++, and unlearn a lot of bad habits easier languages taught me. I spent a lot of time making youtube videos and getting feedback from other developers…eventually I made hundreds of videos.

Throwback to the first Qt video I made…

As my skills increased, so did my understanding on how to teach people C++ and Qt. After years and years I have what I feel is the easy route to learning C++, Qt, and QML.

Eventually I went on to develop Qt professionally, and even working with Qt to create official content for Qt company. I have seen first hand how passionate they are about the technology. This is not simply some company out to make a quick buck, they love development and offer a world class product.

Did I mention its free?

Yes, you can develop with the open source version and never pay a single penny. If you want to develop with the paid version they have multiple options to choose from.

I covered this in a video — how to make money with open source software.

Understanding Qt

Qt is massive, I mean really complex because it does so much but at a high level it is broken up into smaller modules.

Qt Core Non-graphical classes used by other modules.
Qt GUI Base classes for graphical user interface (GUI) components.
Qt Multimedia Classes for audio, video, radio and camera functionality.
Qt Multimedia Widgets Classes for implementing multimedia functionality.
Qt Network Classes to make network programming easier and more portable.
Qt QML Classes for QML and JavaScript languages.
Qt Quick A declarative framework for building highly dynamic applications.
Qt Quick Controls Provides lightweight QML types.
Qt Quick Dialogs Types for creating and interacting with system dialogs.
Qt Quick Test A unit test framework for QML applications.
Qt SQL Classes for database integration using SQL.
Qt Test Classes for unit testing Qt applications and libraries.
Qt Widgets Classes to extend Qt GUI with C++ widgets.

Also see: https://doc.qt.io/qt-5/gettingstarted.html

This is a lot to take in…lets simplify things:

Core — these are the C++ classes needed in all Qt applications

Widgets — these are the GUI classes that run on desktop. Note these look pretty close to native apps and its really super professional looking. Qt Creator, the IDE used to develop Qt is written with Qt Widgets.

QML -these are the GUI classes that run…well…everywhere. I mean it, I have seem the same code run on Windows, Mac, Linux, Android, iOS, Raspberry Pi, other embedded devices.

How do I…

One of the questions I am often asked “how do I <insert topic>?”…

Qt creator itself has an examples tab that is packed with examples, everything from “hello world” to complex 3D animations and real time rendering. Just open Qt Creator, click the examples tab and enjoy.

The entire help system is integrated into Qt Creator, the IDE — you have the complete manual at your finger tips. Also simply highlight something and press F1 on the keyboard to go directory to the help page.

If a picture is worth a thousand words, a video is worth a million

While I am still updating my youtube channel, I have been working away in the background to make full classroom style training on Udemy for C++, Qt, Widgets, and QML.

These courses build on each other starting with beginners then taking those skills to intermediate, and eventually on to advanced topics. From there I have been making self contained classes such as Design patterns and Migrating to Qt 6.

If you are interested here are the links — please note I am in the process of recording these over again for Qt 6 which was just released, current students of the Qt 5 courses will get the Qt 6 courses for free.

If you have zero experience, I would recommend starting with Qt Core beginners. If you already know some C++ start with Qt Core Intermediate. You can also watch all the youtube videos free even without any advertisements.

Also we have a rich community of developers in the VoidRealms facebook group — Im in there all the time asking questions and helping others.

Free tutorials on youtube
https://www.youtube.com/user/VoidRealms/videos

Qt 5 Core for beginners with C++
https://www.udemy.com/course/qt-core-for-beginners/?referralCode=E2115FC6B3CC3BD742AF

Qt 5 Core Intermediate with C++
https://www.udemy.com/course/qt-core-intermediate/?referralCode=1F1A60AF279FEE1719CD

Qt 5 Core Advanced with C++
https://www.udemy.com/course/qt-core-advanced/?referralCode=8DB432110F38B253D251

Qt 5 Widgets for beginners with C++
https://www.udemy.com/course/qt-widgets-beginners/?referralCode=1B2FA9787D88D97D38D3

QML for beginners with Qt 5
https://www.udemy.com/course/qml-for-beginners/?referralCode=3B69B9927B587BBF40F1

Qt 5 Design Patterns
https://www.udemy.com/course/qt-5-design-patterns/?referralCode=3C2C41D87AB3A17B395F

Migrating to Qt 6
https://www.udemy.com/course/migrating-to-qt-6/?referralCode=F4775D810BD9551083B6

Awarded Content Creator in the 2020 Qt Champion Awards:

“Bryan has a few courses available on Udemy, specifically his course on Qt 5 Design Patterns and also has a popular group on Facebook which helps others with their Qt questions as well. For his work alone in creating the Qt 5 training course online for everyone to benefit from it was easy to make him our year’s Content Creator.”

Follow me on:

YouTube: https://www.youtube.com/user/VoidRealms

Facebook: https://www.facebook.com/groups/1400884323467285

Udemy: https://www.udemy.com/user/bryan-cairns/

--

--