Results 1 to 9 of 9

Thread: Using QPropertyAnimation with QGraphicsPixmapItem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Using QPropertyAnimation with QGraphicsPixmapItem

    Well, it must be in your definition of the class. Following works fine on my system:
    Qt Code:
    1. class MyPixmap : public QObject, public QGraphicsPixmapItem
    2. {
    3. Q_OBJECT
    4. Q_PROPERTY (qreal rotation READ rotation WRITE setRotation)
    5. };
    6.  
    7. int main(int argc, char **argv)
    8. {
    9. QApplication app(argc, argv);
    10. MyPixmap *it = new MyPixmap();
    11. QPropertyAnimation* anim = new QPropertyAnimation(it, "rotation");
    12. qWarning() << anim->propertyName();
    13. delete anim;
    14. delete it;
    15. return 0;
    16. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Using QPropertyAnimation with QGraphicsPixmapItem

    I get: undefined reference to `vtable for MyPixmap'...

  3. #3
    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: Using QPropertyAnimation with QGraphicsPixmapItem

    Well here is the full code. You have to rerun qmake:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class MyPixmap : public QObject, public QGraphicsPixmapItem
    4. {
    5. Q_OBJECT
    6. Q_PROPERTY (qreal rotation READ rotation WRITE setRotation)
    7. };
    8.  
    9. int main(int argc, char **argv)
    10. {
    11. QApplication app(argc, argv);
    12. MyPixmap *it = new MyPixmap();
    13. QPropertyAnimation* anim = new QPropertyAnimation(it, "rotation");
    14. qWarning() << anim->propertyName();
    15. delete anim;
    16. delete it;
    17. return 0;
    18. }
    19.  
    20. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to Lykurg for this useful post:

    Luc4 (28th March 2010)

  5. #4
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Using QPropertyAnimation with QGraphicsPixmapItem

    Yes, now its working... There must be an error in my implementation. I will try to find it. Anyway, another solution was to use a QGraphicsProxyWidget. From the point of view of the performance (of animations for instance), is there any difference between using QGraphicsPixmapItems or other types of items like QGraphicsProxyWidgets? Sometimes I wonder if it would be better to use widgets or items in QGraphicsView to play animations.
    Thanks for the information!

  6. #5
    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: Using QPropertyAnimation with QGraphicsPixmapItem

    I would go for a normal item since it is not so big and heavy like a QGraphicsWidget. But if you only use a small number it does not make a big difference.

Similar Threads

  1. QGraphicsPixmapItem to QGraphicsScene
    By strateng in forum Newbie
    Replies: 5
    Last Post: 27th March 2010, 01:50
  2. Replies: 1
    Last Post: 8th January 2010, 12:21
  3. Replies: 8
    Last Post: 12th November 2009, 00:51
  4. Replies: 2
    Last Post: 11th November 2009, 08:03
  5. Scaling QGraphicsPixmapItem
    By johnsoga in forum Qt Programming
    Replies: 9
    Last Post: 7th May 2009, 17:04

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
  •  
Qt is a trademark of The Qt Company.