How to enforce Q_OBJECT macro usage for classes with signals and slots

Viewed 128

I have a bunch of base classes with defined Q_OBJECT macro and derived classes without it:

class Base : public QObject
{
    Q_OBJECT
public:
    // signals and slots
};

class Derived : public Base
{
    // notice no `Q_OBJECT` macro
public:
    // signals and slots
};

That works fine, but according to Qt docs:

The Q_OBJECT macro must appear in the private section of a class definition that declares its own signals and slots or that uses other services provided by Qt's meta-object system.

Is there any way to stop compilation when Q_OBJECT macro is absent for classes which use Qt meta-system?

PS: I'm using MSVC compiler

0 Answers
Related