I tried to compile a code looking like this:
#ifndef CONTROLLER_H_
#define CONTROLLER_H_
#include
class AbstractClass
{
public:
virtual ~AbstractClass() {}
virtual void update() = 0;
};
class Controller :
public AbstractClass, public QObject
{
Q_OBJECT
public:
Controller();
virtual ~Controller();
virtual void update();
public slots:
void m();
};
#endif /*CONTROLLER_H_*/
If you’re trying to compile it you get an error:
tmp/moc/moc_Controller.cpp:45: error: 'staticMetaObject' is not a member of 'AbstractClass'
tmp/moc/moc_Controller.cpp: In member function 'virtual void* Controller::qt_metacast(const char*)':
tmp/moc/moc_Controller.cpp:61: error: 'qt_metacast' is not a member of 'AbstractClass'
tmp/moc/moc_Controller.cpp: In member function 'virtual int Controller::qt_metacall(QMetaObject::Call, int, void**)':
tmp/moc/moc_Controller.cpp:66: error: 'qt_metacall' is not a member of 'AbstractClass'
make: *** [tmp/objects/moc_Controller.o] Error 1
The error is caused by a bad order of inheritance.
Instead of this
class Controller :
public AbstractClass, public QObject
{
...
you should use this
class Controller :
public QObject, public AbstractClass
{
...
Thanks! It was useful for me.
For me to
Thanks a lot
Useful information, thank you! I had exactly the same problem and now it’s fixed.
thx a lot!=v=
thanks a lot! This was useful. Though, I don’t understand why this problem arises. What does inheritance order influence upon?
I don’t know why the compiler behaves like that. I’m not a C++ expert
Thank you a lot. Really useful
thank you very much.
I have this problem and your good comment help me.
thank you again.
Thanks !
Thank you!
Thank You!
Thank you. You solved one of my great headache.