#define Q_OBJECT \ public: \ static const QMetaObject staticMetaObject; \ virtual const QMetaObject *metaObject() const; \ virtual void *qt_metacast(const char *); \ virtual int qt_metacall(QMetaObject::Call, int, void **); \ QT_TR_FUNCTIONS \ private: \ Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ QT_WARNING_POP \ struct QPrivateSignal {}; \ QT_ANNOTATE_CLASS(qt_qobject, "") # define QT_TR_FUNCTIONS \ static inline QString tr(const char *s, const char *c = Q_NULLPTR, int n = -1) \ { return staticMetaObject.tr(s, c, n); } \ QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = Q_NULLPTR, int n = -1) \ { return staticMetaObject.tr(s, c, n); }
As is Q_OBJECT macro code; Qt which contains a meta-object system; as Metaobject (), qt_metacast (const char *), qt_metacall (QMetaObject :: Call, int, void **); TR, trUtf8 () function and the like;
When the program is compiled, you will see generated by the moc tool moc_xxx.cpp file; this function includes the definition of variables to achieve the function of Q_OBJECT inside the statement, as well as declarations;
Which, qt_metacast (const char * _clname) with qt_metacall (QMetaObject :: Call _c, int _id, void ** _ a) function is associated with signals and slots calls; and we write signal statement function is not implemented the code, However, given the corresponding moc implementation code; function code for all contain QMetaObject :: activate (this, & staticMetaObject, signal_xxx, param_list); reinterpret_cast parameters are all strongly into void * or const void * type of void * form; reinterpret_cast using a converted form the bit loss will not produce such a strong turn static_cast; i.e. stronger intensity value before turn followed is the same, but the type of variable; however const type, when the transfer of the strong adding or adding, as converted to a non-const const type type const_cast patent;