Results 1 to 7 of 7

Thread: Animating many items in a QGraphicsScene

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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 Animating many items in a QGraphicsScene

    Hi! I created a QGraphicsView where I have many objects. These objects have to move in the scene when a button is clicked. The fact is that the major part of these items is not visible and won't be visible even when the animation occurs.

    It seems to me that the view redraws everything even if it is not visible. Is it possible to tell the view to redraw only in case the items are inside the view? Or maybe I have to do this myself by computing somehow which items will be visible or not during the animation and make only them move?

    I need this as the device that will show the animations is very slow, so any reduction of computation would be very useful.
    Thanks!

  2. #2
    Join Date
    Jun 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Animating many items in a QGraphicsScene


  3. #3
    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: Animating many items in a QGraphicsScene

    I already read this. As far as I can see this would be the best: QGraphicsView::MinimalViewportUpdate. Unfortunately it seems this is the default mode, thus it is already applied...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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 many items in a QGraphicsScene

    Quote Originally Posted by Luc4 View Post
    It seems to me that the view redraws everything even if it is not visible.
    No, the view only redraws the items that are at least partially visible.

    Or maybe I have to do this myself by computing somehow which items will be visible or not during the animation and make only them move?
    Your only job is to return proper bounding rectangles for your items.
    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.


  5. #5
    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: Animating many items in a QGraphicsScene

    I can understand... So there is no way to improve the performance? Thanks for your answer!

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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 many items in a QGraphicsScene

    Quote Originally Posted by Luc4 View Post
    So there is no way to improve the performance?
    I didn't say that. First you have to find the bottle neck before you start improving things randomly.
    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.


  7. #7
    Join Date
    Dec 2008
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Animating many items in a QGraphicsScene

    Show us the code of the GraphicsItem you use, so we can help you improving the performance. Maybe you didn't calculate the bounding box acuratley, the fact that made your scene performance bad.

    Best wishes

Similar Threads

  1. QGraphicsScene with lots of static items
    By lari in forum Qt Programming
    Replies: 12
    Last Post: 21st April 2010, 11:21
  2. How to save QGraphicsScene Items to a file?
    By yagabey in forum Qt Programming
    Replies: 5
    Last Post: 28th February 2010, 10:16
  3. Custom items selection in qgraphicsscene
    By yonnak in forum Qt Programming
    Replies: 7
    Last Post: 28th March 2009, 11:32
  4. How could I save Items on a QGraphicsScene?
    By pinkfrog in forum Qt Programming
    Replies: 2
    Last Post: 9th January 2009, 05:03
  5. Adding QGraphicsProxyWidget items into QGraphicsScene
    By yagabey in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2008, 06:33

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.