Results 1 to 6 of 6

Thread: How to accelerate the running speed of the qt program?

  1. #1
    Join Date
    May 2011
    Location
    North Carolina
    Posts
    23
    Thanks
    10
    Qt products
    Qt4

    Default How to accelerate the running speed of the qt program?

    First:

    Qt Code:
    1. QGraphicsItem *pnode = new QGraphicsItem[6376]
    2.  
    3. scene = new QGraphicsScene(0, 0, Xmax*VisZoom, Ymax*VisZoom);
    To copy to clipboard, switch view to plain text mode 

    Then
    add the 6376 items on the scene using:
    Qt Code:
    1. scene->addItem(&pnode)
    To copy to clipboard, switch view to plain text mode 
    As shown below: each red spot represents an item


    However, it becomes very slow if I want to change the size of the 6376 items simultaneously using: piNode[i].setScale. It will take about 30 seconds.

    Moreover, even I use: void QGraphicsView::scale ( qreal sx, qreal sy ) to resize the whole scene, it still cost lots of time.

    What's the problem? Can I speed up the program? Thanks a lot.

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: How to accelerate the running speed of the qt program?

    I don't know, but I'd try and see what happens when making a copy of the nodes and change scale of the items "offline" piNodeCopy[i].setScale and then replacing the node set in the scene.

  3. #3
    Join Date
    May 2011
    Location
    North Carolina
    Posts
    23
    Thanks
    10
    Qt products
    Qt4

    Default Re: How to accelerate the running speed of the qt program?

    Quote Originally Posted by mvuori View Post
    I don't know, but I'd try and see what happens when making a copy of the nodes and change scale of the items "offline" piNodeCopy[i].setScale and then replacing the node set in the scene.
    This is the same, just like replace the items on the scene.

    Actually, it will also take about 30 minutes to show the items on the scene for the first time.

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to accelerate the running speed of the qt program?

    There are several flags that can be used to optimize graphicsView/Scene; I don't have access to the docs at the moment, but they're worth playing with. If you don't need to do things like collision detection, for instance, you can turn it off and save a good deal of computation.There's a decent discussion here of various techniques; read through the comments as well.

  5. The following user says thank you to SixDegrees for this useful post:

    superwave (27th June 2011)

  6. #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: How to accelerate the running speed of the qt program?

    First thing to do is to enable caching for your items. Next thing to do is to put your items into groups and apply an empty QGraphicsEffect on the group. This won't speed up scaling but it will speed up other operations. Next, simplify drawing of items using level-of-detail information. If that's not enough, we'll suggest other things. And avoid using setScale() on items separately, I don't know what you're trying to do but most likely if you are scaling all items then what you really want is to scale the whole scene by calling QGraphicsView::scale().

    Also consider using an OpenGL viewport or switching the view to FullViewportUpdate mode.
    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. The following user says thank you to wysota for this useful post:

    superwave (27th June 2011)

  8. #6
    Join Date
    May 2011
    Location
    North Carolina
    Posts
    23
    Thanks
    10
    Qt products
    Qt4

    Default Re: How to accelerate the running speed of the qt program?

    Quote Originally Posted by SixDegrees View Post
    There are several flags that can be used to optimize graphicsView/Scene; I don't have access to the docs at the moment, but they're worth playing with. If you don't need to do things like collision detection, for instance, you can turn it off and save a good deal of computation.There's a decent discussion here of various techniques; read through the comments as well.
    Thank you so much for your help.

    Quote Originally Posted by wysota View Post
    First thing to do is to enable caching for your items. Next thing to do is to put your items into groups and apply an empty QGraphicsEffect on the group. This won't speed up scaling but it will speed up other operations. Next, simplify drawing of items using level-of-detail information. If that's not enough, we'll suggest other things. And avoid using setScale() on items separately, I don't know what you're trying to do but most likely if you are scaling all items then what you really want is to scale the whole scene by calling QGraphicsView::scale().

    Also consider using an OpenGL viewport or switching the view to FullViewportUpdate mode.
    Thank you very much for your advice. I will try right now.

Similar Threads

  1. running external console program by gui program
    By alireza.mixedreality in forum Qt Programming
    Replies: 4
    Last Post: 24th April 2010, 18:05
  2. Sleep My Program when it running ?
    By nhs_0702 in forum Qt Programming
    Replies: 1
    Last Post: 24th April 2010, 06:30
  3. Qt Program Not running
    By Nishant in forum Newbie
    Replies: 0
    Last Post: 6th April 2010, 19:29
  4. Help me how to know the program is running
    By vql in forum Qt Programming
    Replies: 1
    Last Post: 21st March 2008, 12:43
  5. Replies: 1
    Last Post: 17th May 2006, 00:23

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.