If you have ever worked with C++ for GUI development, chance are that you have heard of Qt. Qt is a free and open source widget toolkit for creating GUI and cross platform applications that run on many platforms such as Linux, Windows, MacOs, Android, etc… with native capabilities and performances. Qt does not provide only GUI API but has also support for networking, audio, serial port, thread, database, etc… It’s one of the biggest framework ever written for C++.

Despite of the framework, Qt also provide a code editor named Qt Creator. Qt Creator is really powerful, it integrates GUI designer for the application, has a good debugger integration, … But let’s be honest: it’s far from being the best code editor. Since I work heavily with Jetbrains products I use Clion, and I am really fast and efficient with it. I have then decided to make Qt works with Clion. Fortunately It can be done easily using CMake.

Please note that the following instructions assume that you have Qt & Clion installed and configured.

The previous instructions should help you building a tiny application, but if you need some features of Qt such as Graphical Interface design, auto MOC, resources files, … You’ll need extra configuration. Fortunately this is not very complicated.

The meta object compiler is one of the core functionality of Qt, it reads a C++ header file and if it finds a Q_OBJECT macro, it will produces a C++ source file containing meta object code for the class. It’s the mechanism that allow signal and slots to work.
To enable the auto moc’ing you’ll only need to add the following instructions to the CMakeLists.txt.