error: undefined reference to `vtable for XXX' in Qt

Originally I have a C++ class and change it to inherit a QWidget. Before the inheritance, the build succeed but not after inheriting from QWidget. Someone in below link said this is because in order to inherit from QWidget, I need to add the macro Q_OBJECT in the class. But during the build, the qmake didn't re-execute to generate the right .moc file. Thus, the error raised.

After re-execute the qmake, the problem is gone!

Ref link: http://hi.baidu.com/asky007/item/a466a7d58558d34dddf9beda

留言

熱門文章