[Qt-creator] Suggestions for 'new class' dialog
hyperquantum at gmail.com
Tue Dec 8 00:27:04 CET 2020
Every time I use the dialog for adding a new class, there is still a
lot that I need to do manually after the files were generated:
1. Add cpp file and often the header file as well to CMakeLists.txt
2. Add GPL header to each file (copy from another file and update the
year if necessary)
3. Add namespace to each file
4. Change naming of include guards (add prefix)
5. Remove comment "// MYCLASS_H" at the #endif line
6. Change "signals" to "Q_SIGNALS" in the header file
7. Change "ClassName *parent" to "ClassName* parent" in the
constructor (if it inherits QObject)
It would be really useful if these actions could be automated as well.
1. It may be possible to add the new files everywhere its peers are
mentioned as well. So add "newclass.cpp" everywhere
"existingclass.cpp" occurs and add "newclass.h" everywhere
"existingclass.h" is found. The existing class should be a similar
class in the same directory.
2. I guess it should be possible to automatically extract the GPL from
an existing file, copy it to the new file, find the copyright line and
change the year(s) mentioned there to the current year.
3. By looking in the bug database I discovered that the wizard already
provides this in a very obscure way. This should be made explicit in
the user interface, either by adding a separate "namespace: " field or
by a visible note mentioning that the namespace can be specified along
the class name.
4. It would be really great if a heuristic could figure out the naming
scheme for include guards from existing header files in the same
5. I wouldn't mind the comment so much if I didn't have to fix the
name of the include guard several times for each header.
6. Maybe add a code style setting that says "don't use the Qt
keywords" and obey that setting.
7. This can be fixed by taking the code style settings into account
when generating the files.
Should I add a separate suggestion for each of these to the bug database?
I've already seen multiple bugs mentioning the third item but they all
seem to be closed. Adding yet another might result in it getting
dismissed again I'm afraid(?)
All issues aside, thanks for this great IDE!
More information about the Qt-creator