2

I'm going through the old Trolltech Qt tutorials as I find them more helpful than the newer ones and an undefined reference to vtable error hits me when I got to a class widget implementing its own signals.

http://doc.trolltech.com/4.0/tutorial-t7.html

Instead of keeping the code separate, I just copied them all in the same .cpp for convenience.

I snooped around and found that a vtable error is caused by an undefined virtual function. However, I didn't omit anything from the tutorial code except the code separation. Omitting the Q_OBJECT macro from lcdrange.h as well as the slots and signals seem to make the project compile. I figure it's void valueChanged(int newValue); at lcdrange.h that is causing the fuss but the tutorial did not provide a definition. I'm sure they won't post code that isn't working so I must be doing something wrong. I'm using C::B(MinGW) if that means anything. I'm also new to C++.

lightburst
  • 231
  • 3
  • 19

1 Answers1

3

MOC must generate code for lcdrange.h and the generated code must be compiled and linked. qmake ensures this for all header files listed in the HEADERS variable. Make sure lcdrange.h is listed in the HEADERS section of your .pro file, and rerun qmake.

Frank Osterfeld
  • 24,815
  • 5
  • 58
  • 70