Disable old (Qt4-style) Signal-Slot syntax in Qt5 code
If you have a shared header file in the project that you can ensure will be included after QObject
, you can do this:
#define SIGNAL(x) static_assert(false, "String-based signal/slot syntax has been disabled in this project")
Same for SLOT
.
If you want to turn it into warning, check out this answer. I definitely agree with you that the string based syntax is a plague and shouldn't occur outside of uic
ed files.
Based on this answer.
You can override the SIGNAL macro in your project if you have a common header that is included in every file.
Make sure it is included after the Qt/QObject includes.
#undef SIGNAL
#define SIGNAL(x) "",nullptr,""); static_assert(false, "String-based signal/slot syntax has been disabled in this project");
This will show an error message when trying to compile a Qt4-style connect statement.