I am using Qt Creator 2.0.1 with Qt 4.7.0 (32 bit) on Windows 7 Ultimate 32 bit.
Consider the following code, which is the minimum for an error to occur:
class T : public QObject, public QGraphicsItem { Q_OBJECT public: T() {} QRectF boundingRect() const {return QRectF();} void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {} }; int main() { T t; return 0; }
The above code snippet causes the following linker errors:
In the `T 'function:
undefined reference to `vtable for T '
undefined reference to `vtable for T '
In the `~ T 'function:
undefined reference to `vtable for T '
undefined reference to `vtable for T '
If I comment out the line containing Q_OBJECT , it compiles fine. I need signal and slots with QGraphicsItem , so I need Q_OBJECT .
What is wrong with the code? Thank.
c ++ qt vtable linker-errors
Donotalo Jan 23 2018-11-11T00: 00Z
source share