Results 1 to 4 of 4

Thread: What is the best way to create my own animated canvas item ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: What is the best way to create my own animated canvas item ?

    ok, I tryed with the following code

    Qt Code:
    1. void CMySprite::advance(int phase)
    2. {
    3. if( frame() != 0 )
    4. setFrame(frame() - 1);
    5.  
    6. QCanvasItem::advance(phase);
    7. }
    To copy to clipboard, switch view to plain text mode 

    ... it works backward and stops when the first image is reached.

    So I would like to reimplement setFrameAnimation() ... but how is it possible to modify the enum FrameAnimationType in order to add my own animation types ? Should I declare my own enum with cycle, oscillation and my own values or is there another way to do it ?

    About advance(), I also tryed without calling the base class method and it works as well, is it really necessary to call the base class method ?

    thanks in advance

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

    Default Re: What is the best way to create my own animated canvas item ?

    Quote Originally Posted by yellowmat
    So I would like to reimplement setFrameAnimation() ... but how is it possible to modify the enum FrameAnimationType in order to add my own animation types ? Should I declare my own enum with cycle, oscillation and my own values or is there another way to do it ?
    Maybe you could use one of existing types? If not, you can always add a new method to the class.

    About advance(), I also tryed without calling the base class method and it works as well, is it really necessary to call the base class method ?
    The base class implementation moves the object. If your object is not to be moved automatically, you can skip the base call, but there is nothing wrong in making it, so I'd leave it as it is.

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

    yellowmat (18th July 2006)

Similar Threads

  1. When is the best time to delete a QCanvasItem
    By irudkin in forum Qt Programming
    Replies: 12
    Last Post: 8th March 2007, 21:28
  2. Setting focus on Canvas
    By Kapil in forum Qt Programming
    Replies: 10
    Last Post: 17th May 2006, 12:55
  3. how change the QListBox item position by pixel
    By roy_skyx in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2006, 01:34

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.