Tuesday 23 September 2008

Fixing undefined reference to vtable errors in QT3

Assuming that you have added the Q_OBJECT macro to your class definition then the problem is that you are not generating and referencing the moc file for that class.
Easiest way to fix is to run qmake on your src.pro file (if you are using kdevelop, making sure that qmake is the correct one for your version, QT3 and QT4 qmake are not the same.)

Alternatively, run

moc -o myheader.moc myheader.h

and include the myheader.moc file in your project. It will need to be updated every time you change your SIGNALS or SLOTS in that class, so you may want to automate its creation.

No comments: