Results 1 to 4 of 4

Thread: qGraphicsPixmapItem & QObject

  1. #1
    Join Date
    Sep 2010
    Location
    Russia, Moscow
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default qGraphicsPixmapItem & QObject

    Hello!

    Can u give me advice?
    I have custom class, whics inherits from qGraphicsPixmapItem.
    Qt Code:
    1. class mapObject : public QGraphicsPixmapItem
    To copy to clipboard, switch view to plain text mode 
    Now i want to add some signals to it.
    What is the best way to do it? Inherit from OQbject ? From QGraphicsObject?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: qGraphicsPixmapItem & QObject

    Best is:
    Qt Code:
    1. class mapObject : public QObject, public QGraphicsPixmapItem
    2. {
    3. Q_OBJECT
    4. };
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2010
    Location
    Russia, Moscow
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qGraphicsPixmapItem & QObject

    in header:
    Qt Code:
    1. class mapObject : public QObject, public QGraphicsPixmapItem
    2. {
    3. Q_OBJECT
    4. public:
    5. mapObject(QString name, QGraphicsScene *scene, QMenu * contextMenu = 0);
    6. ~mapObject();
    7. };
    To copy to clipboard, switch view to plain text mode 

    constructor:
    Qt Code:
    1. mapObject::mapObject(QString name, QGraphicsScene *scene, QMenu * contextMenu) : QObject(0), QGraphicsPixmapItem(0, scene)
    2. {
    3. .....
    4. }
    To copy to clipboard, switch view to plain text mode 

    After compile:
    Qt Code:
    1. D:\WORK\DAssistant/mapObject.cpp:3: undefined reference to `vtable for mapObject'
    2. D:/WORK/DAssistant/mapObject.cpp:50: more undefined references to `vtable for mapObject' follow
    3. :-1: error: collect2: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 

    Any ideas?

  4. #4
    Join Date
    Sep 2010
    Location
    Russia, Moscow
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qGraphicsPixmapItem & QObject

    Thanks a lot...Running QMAKE FTW!

    problem solved. =)

Similar Threads

  1. Simplest example for QGraphicsPixmapItem
    By sincnarf in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2012, 14:24
  2. Using QPropertyAnimation with QGraphicsPixmapItem
    By Luc4 in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2010, 09:47
  3. QGraphicsPixmapItem to QGraphicsScene
    By strateng in forum Newbie
    Replies: 5
    Last Post: 27th March 2010, 01:50
  4. Scaling QGraphicsPixmapItem
    By johnsoga in forum Qt Programming
    Replies: 9
    Last Post: 7th May 2009, 17:04
  5. Rotate QGraphicsPixmapItem
    By durbrak in forum Qt Programming
    Replies: 7
    Last Post: 15th April 2007, 14:51

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.