Results 1 to 1 of 1

Thread: Using the animation framework with graphic items

  1. #1
    Join Date
    Oct 2009
    Posts
    47
    Thanks
    10

    Exclamation Using the animation framework with graphic items

    Hi guys, so I know its very easy to use the animation framework with widgets but I'm having issues using it with graphic items.

    I know its possible because of this website:

    http://pepper.troll.no/s60prerelease...-overview.html

    But for instance I'm trying to modify the setPositionAt() property to move the graphic items around the window (an animation) and I get an error saying geometry property isn't found in the graphic items property, I also tried "setPositionAt" still no luck.

    ANy ideas what I'm doing wrong? What property do I need to maniuplate or tell the QPropertyAnimation that I want to maniuplate to allow movement of the graphics object? If I was hard coding it with a for loop, I would modify the setPositionAt(step,Qpoint) and it would work (infact I have done this) but I want to use the animation framework instead of hardcoding it.

    This will work for a widget to make a widget animate around the screen:
    Qt Code:
    1. QPushButton button("Animated Button");
    2. button.show();
    3.  
    4. QPropertyAnimation animation(&button, "geometry");
    5. animation.setDuration(10000);
    6. animation.setStartValue(QRect(0, 0, 100, 30));
    7. animation.setEndValue(QRect(250, 250, 100, 30));
    8.  
    9. animation.start();
    To copy to clipboard, switch view to plain text mode 


    But how can I do this with a graphics item rather than a widget? My class does inhert from a QObject.


    The website says to do the following:
    When you want to animate QGraphicsItems, you also use QPropertyAnimation. However, QGraphicsItem does not inherit QObject. A good solution is to subclass the graphics item you wish to animate. This class will then also inherit QObject. This way, QPropertyAnimation can be used for QGraphicsItems. The example below shows how this is done. Another possibility is to inherit QGraphicsWidget, which already is a QObject.
    Qt Code:
    1. class Pixmap : public QObject, public QGraphicsPixmapItem
    2. {
    3. Q_OBJECT
    4. Q_PROPERTY(QPointF pos READ pos WRITE setPos)
    5. ...
    To copy to clipboard, switch view to plain text mode 
    As described in the previous section, we need to define properties that we wish to animate.
    Last edited by technoViking; 10th November 2009 at 06:11.

Similar Threads

  1. Replies: 0
    Last Post: 6th November 2009, 21:59
  2. Can you use the animation framework on graphic items?
    By technoViking in forum Qt Programming
    Replies: 1
    Last Post: 6th November 2009, 19:34
  3. Reshape graphic items
    By jsmith in forum Qt Programming
    Replies: 3
    Last Post: 31st July 2009, 07:46
  4. Qt Animation Framework install and examples?
    By been_1990 in forum Installation and Deployment
    Replies: 2
    Last Post: 4th July 2009, 19:17
  5. How to restrict graphic items in view
    By aamer4yu in forum Qt Programming
    Replies: 4
    Last Post: 13th November 2006, 07:46

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.