Results 1 to 2 of 2

Thread: MOC not running for class derived from QGraphicsObject

  1. #1
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default MOC not running for class derived from QGraphicsObject

    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 :

    Qt Code:
    1. class CmgDiagram : public QGraphicsObject
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. CmgDiagram(QGraphicsScene *pScene, QGraphicsObject * parent = 0);
    7.  
    8. QRectF boundingRect() const;
    9. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    10.  
    11. CmgDiagramItem *getItem( QString sPath );
    12. void WriteXML( QXmlStreamWriter *pXML );
    13.  
    14. private:
    15. QGraphicsScene *m_pScene;
    16. CmgDiagramItem *m_pMainItem;
    17.  
    18. private slots:
    19. void selectionChanged( void );
    20. };
    To copy to clipboard, switch view to plain text mode 

    Why doens't this work ?

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

    Best regards,
    Marc

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: MOC not running for class derived from QGraphicsObject

    Did you run qmake after adding the Q_OBJECT macro to the class?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    marcvanriet (24th October 2010)

Similar Threads

  1. add a derived class to a qtdesigner project
    By franco.amato in forum Qt Programming
    Replies: 1
    Last Post: 12th February 2010, 07:20
  2. no frame on Qlabel derived class
    By tupu_83 in forum Qt Programming
    Replies: 2
    Last Post: 19th November 2008, 16:01
  3. Use QWidget derived class in Dialog
    By qtneuling in forum Qt Tools
    Replies: 2
    Last Post: 17th May 2008, 23:29
  4. rtti() of derived class
    By quickNitin in forum Newbie
    Replies: 4
    Last Post: 8th October 2006, 14:20
  5. Signal/slot looking in base class, not derived class
    By georgie in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 07:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.