Re:Verdigris: Qt Without Moc
by arketyp on Tuesday December 31, 2019 @01:53AM
(#21919429)
The convenience of the MOC is its raison d'être. The minor pain point for me is practically being forced to use the Qt Creator IDE. I'm happy to see a possible best of both worlds solution like this.
[ Parent
| on HN ]
Why do you feel forced to use Qt Creator? I used Visual Studio for years, and these days I just use Vim. While Qt Creator is a great IDE, it has never felt necessary to me.
I've coded QT for a few years. Have never even opened the QT Creator IDE.
I used to do this too but I started using the form designer and uic + uiloader and it was a nice boost to productivity for creating lame but necessary dialogs.
Most C++ build systems have support for moc generation - CMake even has CMAKE_AUTOMOC which can automatically do it for you with no further intervention with some caveats.
No need to use Qt creator. Most C++ build systems support moc out of the box, or with minor adjustments.
Qt Creator doesn't even get involved in the build once it has started qmake - a qmake .pro[ject] file is nothing like a Visual Studio project file. You are supposed to make edits other than adding or removing source files by hand. So you really don't need Qt Creator for moc.
Note that qmake is generally easiest for tiny programs such as bug reproducers. For anything nontrivial, it's better to use CMake. Most advanced functionality in qmake is undocumented and weird. Qt itself is moving to CMake with Qt 6.
I was trying to figure out how to do MOC from gnu make when I came across this, the only other option I saw was to run qmake and then run that generated makefile from my makefile. Of those two options verdigris seemed to be the better choice to me.
Thanks, I guess I should have kept on looking.
CMake also has automoc built-in. You need to do next to nothing for moc support with CMake.