Hi All,
Sometimes the linking stage of compiling might fail with the rather confusing error:
undefined reference to `vtable for MyWidget`
The short answer is:
Don't put class definitions in .cpp files when they have the Q_OBJECT macro.
ie if there are signals or slots in a class, ensure the definition is in a header file. Otherwise, moc doesn't see it and do all its magic, and so a lot of required code isn't generated.
Q: What is a vtable? A: Virtual Table
The vtable is an internal structure used for virtual overriding etc, which is heavily used in QT.
ie:
class MyWidget : public QWidget
{
Q_OBJECT
public slots:
virtual void show(); // vtable will be used for this.
};
Hope that helps someone
Debboy