Qt-MissingQObjectMacro

Finds QObject derived classes that do not have a Q_OBJECT macro

Required inputs: IR

Reasons to use Q_OBJECT

  • Signals and slots
  • QObject::inherits
  • qobject_cast
  • metaObject()->className()
  • Use your custom widget as a selector in Qt stylesheets

Reasons not to use Q_OBJECT

  • Templated QObjects
  • Compilation time

This check can not be used with pre-compiled headers support. This check does not have false positives, but it is not included in level ≤ 1 because the missing Q_OBJECT might be intentional.

This rule is based on clazy rule missing-qobject-macro

Possible Messages

Key

Text

Severity

Disabled

missing_qobject_macro

Class is missing a Q_OBJECT macro.

None

False

no_macros

Qt macros are missing in Qt system include files. Either include Qt via user files or disable the advanced toolchain option “no_macro_invocations_for_system_headers”.

None

False

Options

level

level : int = 2

Importance level of the rule as given for clazy. 0 is most desirable, higher values fall off in quality.