Results 1 to 4 of 4

Thread: Animating QGraphicsPixmapItem

  1. #1
    Join Date
    Jun 2013
    Posts
    46
    Thanks
    24
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Post Animating QGraphicsPixmapItem

    I have 2 QImages(img1, img2) loaded in 2 QGraphicsPixmapItem(imgItem1, imgItem2)

    Both are loaded in Graphics view
    I'm overlaying the images

    I want to create a small animation of QGraphicsPixmapItem within the graphicsview, when a button is clicked
    such that it imgItem2 starts at rotation = 0 & rotates until a predefined rotation angle within 5seconds
    then translates it by a predefined rowOffset and ColumnOffset within 5seconds

    I can rotate & translate easily
    but how do i create an animation of it with QTimer? QAnimation only works on objects like buttons/... not images?

    looked at certain example sourc code, but i'm not winning

    Please assist me
    A basic example would be highly appreciated

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Animating QGraphicsPixmapItem

    You can use QPropertyAnimation together with QSequentialAnimationGroup. Since the former can only animate properties, you need a subclass of QGraphicsItem that is derived from QObject. You can obtain that either by subclassing both QObject and QGraphicsPixmapItem, by subclassing QGraphicsObject and teaching it to show a pixmap or by wrapping a QGraphicsPixmapItem into QGraphicsObject.
    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:

    2lights (27th August 2013)

  4. #3
    Join Date
    Jun 2013
    Posts
    46
    Thanks
    24
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: Animating QGraphicsPixmapItem

    Thanks, though I want to create a small animation

    is there no easier faster process
    because its not a requirement of program
    I just want to add a cool animated touch

    Any ideas?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Animating QGraphicsPixmapItem

    Quote Originally Posted by 2lights View Post
    Thanks, though I want to create a small animation
    How does a "small animation" differ from an "animation"?


    is there no easier faster process
    because its not a requirement of program
    I just want to add a cool animated touch
    It's about 6 lines of code, if you're looking for something simpler, you need to define what "simplicity" means for you.
    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.


Similar Threads

  1. Animating QDockWidget
    By vajindarladdad in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2021, 17:27
  2. Animating a QwtPolarPlot
    By bwnicewo in forum Qt Programming
    Replies: 0
    Last Post: 8th June 2012, 17:54
  3. Animating QSplashScreen
    By pssss in forum Qt Programming
    Replies: 3
    Last Post: 3rd September 2011, 11:39
  4. Animating QDockWidget
    By vajindarladdad in forum Newbie
    Replies: 1
    Last Post: 15th December 2008, 08:02
  5. animating a toolbar??!?
    By nupul in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2006, 08:27

Tags for this Thread

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.