Skip to content


QT – Undefined reference to virtual table

I wrote a more detailed summary about this error in this post.

Recently I struggled with linking my QT application. I always got an “Undefined reference to virtual table” error. I googled around and found lots of reference to this problem, but I haven’t found a solution that solved my problem. I figured out that somehow it is related to signals and slots or some other QT specific magic. Finally I found what was my problem. I used the Q_OBJECT macro in my class definition. I wrongly thought that is needed if I inherit from a QObject. That is not the case. You have to use it only if you have signals and/or slots specified in your inherited class. If you check my former post you will find my ArthurCanvas class definition starts like this:

class ArthurCanvas : public QLabel
{
// Q_OBJECT

Now, you know why the Q_OBJECT macro is commented out.

Posted in QT Programming.

Tagged with , , , .