PDA

View Full Version : qGraphicsPixmapItem & QObject



dkoryagin
24th September 2010, 09:59
Hello!

Can u give me advice?
I have custom class, whics inherits from qGraphicsPixmapItem.


class mapObject : public QGraphicsPixmapItem

Now i want to add some signals to it.
What is the best way to do it? Inherit from OQbject ? From QGraphicsObject? :)

Lykurg
24th September 2010, 10:01
Best is:
class mapObject : public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
};

dkoryagin
24th September 2010, 11:06
in header:


class mapObject : public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
public:
mapObject(QString name, QGraphicsScene *scene, QMenu * contextMenu = 0);
~mapObject();
};


constructor:


mapObject::mapObject(QString name, QGraphicsScene *scene, QMenu * contextMenu) : QObject(0), QGraphicsPixmapItem(0, scene)
{
.....
}


After compile:


D:\WORK\DAssistant/mapObject.cpp:3: undefined reference to `vtable for mapObject'
D:/WORK/DAssistant/mapObject.cpp:50: more undefined references to `vtable for mapObject' follow
:-1: error: collect2: ld returned 1 exit status


Any ideas?

dkoryagin
24th September 2010, 11:22
Thanks a lot...Running QMAKE FTW! :p

problem solved. =)