译文
-
对于那些没有继承自QObject但却想拥有反射能力的类型,Q_GADGET是Q_OBJECT的轻量化版本。
-
和Q_OBJECT一样,Q_GADGET也必须出现在类定义的私有区域。
-
有Q_GADGET时,可以有Q_ENUM, Q_PROPERTY 和Q_INVOKABLE,但不能有signals和slots。
-
Q_GADGET使类成员staticMetaObject可用。
原文:
The Q_GADGET macro is a lighter version of the Q_OBJECT macro for classes that do not inherit from QObject but still want to use some of the reflection capabilities offered by QMetaObject. Just like the Q_OBJECT macro, it must appear in the private section of a class definition.
Q_GADGETs can have Q_ENUM, Q_PROPERTY and Q_INVOKABLE, but they cannot have signals or slots.
Q_GADGET makes a class member, staticMetaObject, available. staticMetaObject is of type QMetaObject and provides access to the enums declared with Q_ENUMS.