Results 1 to 6 of 6

Thread: Showing QGraphicsEllipseItems extremely slow

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Showing QGraphicsEllipseItems extremely slow

    Hi,

    I have an application showing thousand of items (lines, points, polygons).
    the user can click a button to show/hide all those items.

    I'm porting that application from Qt3 to Qt4 (4.5.1).
    The application was working greatily in Qt3, but after porting it to Qt4 I'm noticing it is extremely slower showing and hiding items. Debugging it deeply I found out that the bottleneck is the showing of points (QGraphicsEllipseItems) that is causing the application to get stuck. Actually to show 10000 points (QGraphicsEllipseItems w = 4 and h = 4) it took more that 5 minutes while in Qt3 it was almost instantaneous.
    The same amount of Lines and Polygons is shown quite fast (just a few seconds).

    I disabled the indexing in QGraphicsScene just to avoid it was causing the slowness, but it seems it didn't cause any improvement.

    Am I missing something?
    Here is part of the code I'm using to create and show the items. Attache is the whole Qt project.


    Qt Code:
    1. MainWindow::MainWindow( QWidget * parent, Qt::WindowFlags flags)
    2. : QMainWindow(parent, flags)
    3. {
    4. ...
    5. scene = new QGraphicsScene(this);
    6. scene->setSceneRect(0, 0, 800, 600);
    7. scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    8. scene->setBackgroundBrush(Qt::black);
    9. gvView->setScene(scene);
    10.  
    11. // create the items
    12. createNPoints(10000);
    13. }
    14.  
    15. /*
    16.  * create some points
    17.  */
    18. void MainWindow::createNPoints(int num)
    19. {
    20. for( int i = 0; i < num; i++ )
    21. createPoint();
    22. }
    23.  
    24. void MainWindow::createPoint()
    25. {
    26. QGraphicsEllipseItem *p = scene->addEllipse(qrand()%int(scene->width()),qrand()%int(scene->height()), 4, 4);
    27.  
    28. QColor c(qrand()%32*8,qrand()%32*8,qrand()%32*8);
    29. p->setPen(c);
    30. p->setBrush(c);
    31. p->setZValue(qrand()%256);
    32.  
    33. pointsList.append(p);
    34. }
    35.  
    36. /*
    37.  This is the slot called when the user clicks the button to show the items
    38. */
    39. void MainWindow::showPoints(bool yes)
    40. {
    41. for(int i = 0; i < pointsList.count(); i++)
    42. {
    43. if(yes)
    44. pointsList[i]->show();
    45. else
    46. pointsList[i]->hide();
    47. }
    48. }
    To copy to clipboard, switch view to plain text mode 


    Thanks in advance for your help.
    Attached Files Attached Files

Similar Threads

  1. Replies: 2
    Last Post: 17th September 2010, 16:38
  2. Image-based widgets showing is too slow in Qt 4.2.1
    By mkrentovskiy in forum Qt Programming
    Replies: 11
    Last Post: 8th August 2007, 22:20
  3. QProcess extremely slow on Windows?
    By Pepe in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2007, 00:25
  4. QTextEdit extremely slow with links
    By elahav in forum Qt Programming
    Replies: 2
    Last Post: 25th May 2006, 18:00
  5. Qt interface running extremely slowly...
    By jazztpt in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2006, 11:12

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.