Q_OBJECT in cpp file
Hi
I have a problem with the macro Q_OBJECT. My source code:
- // myclass.h
- #ifndef MYCLASS_H
- #define MYCLASS_H
- #include <QObject>
- #include <QtCore>
- class MyClassPrivate;
- {
- Q_OBJECT
- Q_DECLARE_PRIVATE(MyClass)
- public:
- signals:
- public slots:
- private:
- void* const d_ptr;
- };
- #endif // MYCLASS_H
- // myclass.cpp
- #include "myclass.h"
- Q_OBJECT
- public:
- signals:
- public slots:
- };
- d_ptr(new MyClassPrivate())
- {
- }
when compiling, I got error “undefined reference to `vtable for MyClassPrivate’”. But if I comment the Q_OBJECT declaration inside MyClassPrivate then compilation successful. Could anyone tell me why? And what if I don’t use Q_OBJECT in MyClassPrivate?
Thanks for help!
4 replies
You must log in to post a reply. Not a member yet? Register here!


