Results 1 to 5 of 5

Thread: Performance of scene(QGraphicsScene) with update();

  1. #1
    Join Date
    Jan 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Performance of scene(QGraphicsScene) with update();

    I am trying to update graphics scene by calling update() . When i wanted to scroll down the scene after some time, the application performs the action after some time(15 sec or more). I am updating the scene in the particular view port region. Totally the application gets slow like after 1hr or more and does not respond. Is there any solution to this so that application does not get slow for continuous running

    Sample Code :

    while(true)
    {
    scene->update(view->mapToScene(view->visibleRegion().boundingRect()).boundingRect().to Rect());
    sleep(1);
    }

    The above code runs in a thread.
    Last edited by mukunda; 11th January 2011 at 11:33. Reason: updated contents

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Performance of scene(QGraphicsScene) with update();

    Hi!

    Lacking a more precise task description, i would recommend using a timer in the GUI-main-thread instead of a sleeploop in a separate thread. I'm pretty sure QGraphicsScene is not thread safe and intended to be accessed only from the main-thread. Don't use QTimer::singleshot, but a periodic timer with QTimer::start for better reliability. The delay should be related to your screen update frequency. DVI = 60Hz thus 16ms interval.

    HIH

    Johannes

  3. #3
    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: Performance of scene(QGraphicsScene) with update();

    I'm suprised the application doesn't crash since you are accessing QObjects across threads.

    Anyway, if you need such an arbitrary update then most likely you have implemented something incorrectly in your scene. A change to the scene should cause it to update automatically and not using a timer of any sort. It's likely you don't call update() on some item when it changes.
    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.


  4. #4
    Join Date
    Jan 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Performance of scene(QGraphicsScene) with update();

    Quote Originally Posted by wysota View Post
    I'm suprised the application doesn't crash since you are accessing QObjects across threads.

    Anyway, if you need such an arbitrary update then most likely you have implemented something incorrectly in your scene. A change to the scene should cause it to update automatically and not using a timer of any sort. It's likely you don't call update() on some item when it changes.
    I've the application like data will be coming from a device continously by which the items in the scene should be shown with color like digital values(green or red) and running values on the scene.so i've to update the scene for every 20ms.

  5. #5
    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: Performance of scene(QGraphicsScene) with update();

    Quote Originally Posted by mukunda View Post
    I've the application like data will be coming from a device continously
    So when the data comes, process it and as part of processing call update() on any item that is changed by the data.

    by which the items in the scene should be shown with color like digital values(green or red) and running values on the scene.so i've to update the scene for every 20ms.
    Updating every 20ms yields little sense. You won't be able to notice such frequent updates (50Hz), you'll just be wasting processing cycles. Data processing should also be a result of receiving a notification that there is something to be processed, not upon a timer timeout (unless you have no other choice but then I'd reduce the frequency to around 10Hz max).
    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. QGraphics View Scene performance with polylines
    By iampowerslave in forum Qt Programming
    Replies: 0
    Last Post: 15th November 2010, 17:03
  2. Update scene after moving QGraphicsItem
    By rogerholmes in forum Newbie
    Replies: 1
    Last Post: 19th January 2010, 05:08
  3. QGraphicsScene performance
    By Aceman2000 in forum Qt Programming
    Replies: 4
    Last Post: 2nd June 2008, 18:10
  4. How to update scene after removing items
    By nileshsince1980 in forum Qt Programming
    Replies: 4
    Last Post: 20th September 2007, 09:56
  5. How to find out scene update time
    By nileshsince1980 in forum Qt Programming
    Replies: 5
    Last Post: 20th September 2007, 09:46

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.