The day Kate Gregory enjoyed Qt

At my company we use C++ for everything, from creating microservices to website backends and as a generator for website frontends, I mean, we do a lot of c++. And because of that we always need more c++ people, but sometimes it’s hard to find developers, but it’s easy to find php / python / javascript ones. Because of that we hired Kate Gregory’s famous c++ course – “Teaching the Teacher” to train current C++ developers to teach C++. (now, that’s a lot of ‘C++’ in a simple sentence, I know. bear with me.)

For those that doens’t know, Kate Gregory is somebody that uses, advocates our beloved language even before I was born, and talks all over the world about C++ and also do trainings for companies, And so I enlisted to be her student.

It was a really pleasant course going thru how to proplery explain C++ for people that know how to program but don’t know how to C++, and for that I’m grateful. But then when I commented out about Qt in the middle of the class she rolled her eyes, that made me feel a bit uneasy so I talked to her on why the eye-roll. “Qt is not c++”, and I tougth this was already settled down for years, so I asked her if she would be open to see some simple c++ code written in Qt and tell me what she thinks of it. “Well, Yes. but people already tried and it was not good”.

Then I tried, and when you are showing Qt to people that are interested in the language there’s a few things that you should not try to talk about:

  • Don’t talk about Qt Creator, it’s common that they have a favorite editor, and Qt is unrelated to Qt Creator
  • Don’t talk about Designer, drag’n drop is not a feature for algorithm-minded people.
  • Don’t talk about QtWidgets, it’s a nice feature to have and everybody knows that Qt has it, talk about something else.
  • Don’t talk about qmake, tha’s irrelevant, every IDE has a way of building software, and if they don’t use a IDE they know how to use a Makefile or similar.

What I actually talked about, to remove some misconceptions about “Qt is for Widgets, Qt is Not C++”

  • moc is uneeded, you can create complete Qt applications without it.
    • you don’t need to use moc-like code if you don’t inherit from QObject
    • if you inherit you need to use moc-like code, but that can be done with:
      • moc, easiest way.
      • hand written if you feel like it (but why?)
      • use Verdigris a header library that generates moc-style code.
  • Create something that’s unrelated to a Widget, use QNetwork, Threads or somerthing.

I’v created the following source codes, all compile without moc, all are clean c++ code for people that don’t belive Qt can be compiled with a plain compiler, all of them are *way* easier to read and write than anything that the STL can provide, and I’v showed them to Kate. (wordpress don’t let me update cpp files so I renamed it to txt)

After looking at them Kate said “You are actually the first person to show me Qt code that’s nice to look, this is actually pleasant.”, I realized that whenever We (and by we I mean KDE, Qt Company, Qt Advocates) try to advocate Qt to C++ developers we attack in the wrong front, let’s put less focus on Widgets / QML and more focus on easy of use for things that STL provides and Qt does better, or for things that STL *should* provide but doesn’t (like QString vs std::string – it’s 2018 and till today there’s no codepoint support for utf-8 in it, sigh).

Leave a Reply

Your email address will not be published. Required fields are marked *