PDA

View Full Version : MOC not running for class derived from QGraphicsObject



marcvanriet
24th October 2010, 02:31
Hi,

I am writing a diagramming object to use in a graphics scene. It must be capable of emitting some signals, so I derived it from QGraphicsObject.

When I build my program, I get a linker error saying "error: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CmgDiagram::metaObject(void)const " ...". This is typically when moc isn't executed to generate the extra methods for the class. There is no moc_... file in my build output directory either.

This is the definition of my class :


class CmgDiagram : public QGraphicsObject
{
Q_OBJECT

public:
CmgDiagram(QGraphicsScene *pScene, QGraphicsObject * parent = 0);

QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

CmgDiagramItem *getItem( QString sPath );
void WriteXML( QXmlStreamWriter *pXML );

private:
QGraphicsScene *m_pScene;
CmgDiagramItem *m_pMainItem;

private slots:
void selectionChanged( void );
};

Why doens't this work ?

MOC runs just fine for another class in the same project that is derived from QGraphicsView.

Best regards,
Marc

wysota
24th October 2010, 02:40
Did you run qmake after adding the Q_OBJECT macro to the class?