Results 1 to 5 of 5

Thread: slowness QGraphicsView setScene

  1. #1
    Join Date
    Apr 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default slowness QGraphicsView setScene

    Hello,

    I was trying to implement a design using Graphics View/Scene method. I am seeing a lot of time being consumed in QGraphicsView::setScene
    To reproduce in a QT known code,
    I changed the chip demo as follows mainwindow.cpp
    93c93
    < for (int i = -11000; i < 11000; i += 110) {
    ---
    > for (int i = -110000; i < 110000; i += 110) {
    96c96
    < for (int j = -7000; j < 7000; j += 70) {
    ---
    > for (int j = -70000; j < 70000; j += 70) {
    98,99c98,99
    < qreal x = (i + 11000) / 22000.0;
    < qreal y = (j + 7000) / 14000.0;
    ---
    > qreal x = (i + 110000) / 22000.0;
    > qreal y = (j + 70000) / 14000.0;

    I made the data much bigger. Now, I see the following stack:
    #0 0x0000000000981a3f in qt_closestItemFirst ()
    #1 0x000000000095ab58 in QAlgorithmsPrivate::qSortHelper<QList<QGraphicsIte m*>::iterator, QGraphicsItem*, bool (*)(QGraphicsItem const*, QGraphicsItem const*)> ()
    #2 0x000000000095abf3 in QAlgorithmsPrivate::qSortHelper<QList<QGraphicsIte m*>::iterator, QGraphicsItem*, bool (*)(QGraphicsItem const*, QGraphicsItem const*)> ()
    #3 0x000000000095abf3 in QAlgorithmsPrivate::qSortHelper<QList<QGraphicsIte m*>::iterator, QGraphicsItem*, bool (*)(QGraphicsItem const*, QGraphicsItem const*)> ()
    #4 0x000000000095abf3 in QAlgorithmsPrivate::qSortHelper<QList<QGraphicsIte m*>::iterator, QGraphicsItem*, bool (*)(QGraphicsItem const*, QGraphicsItem const*)> ()
    #5 0x000000000095abf3 in QAlgorithmsPrivate::qSortHelper<QList<QGraphicsIte m*>::iterator, QGraphicsItem*, bool (*)(QGraphicsItem const*, QGraphicsItem const*)> ()
    #6 0x000000000095abf3 in QAlgorithmsPrivate::qSortHelper<QList<QGraphicsIte m*>::iterator, QGraphicsItem*, bool (*)(QGraphicsItem const*, QGraphicsItem const*)> ()
    #7 0x000000000095abf3 in QAlgorithmsPrivate::qSortHelper<QList<QGraphicsIte m*>::iterator, QGraphicsItem*, bool (*)(QGraphicsItem const*, QGraphicsItem const*)> ()
    #8 0x0000000000985fdc in QGraphicsSceneBspTreeIndexPrivate::sortItems ()
    #9 0x0000000000986ab9 in QGraphicsSceneBspTreeIndex::items ()
    #10 0x00000000009677aa in QGraphicsScene::items ()
    #11 0x0000000000968f5e in QGraphicsScene::itemsBoundingRect ()
    #12 0x0000000000969167 in QGraphicsScene::sceneRect ()
    #13 0x00000000009928d2 in QGraphicsView::sceneRect ()
    #14 0x000000000099293a in QGraphicsViewPrivate::recalculateContentSize ()
    #15 0x0000000000993a6c in QGraphicsView::setScene ()
    #16 0x0000000000431607 in MainWindow::MainWindow ()
    #17 0x0000000000431297 in main ()

    Any ideas on what I am doing wrong? I am using qt-everywhere-opensource-src-4.6.1

    Thanks -- RK

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

    Default Re: slowness QGraphicsView setScene

    What exactly is the problem? Does it crash or is it slow? Do you have enough RAM to keep all the extra 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.


  3. #3
    Join Date
    Apr 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: slowness QGraphicsView setScene

    It is slow. I have plenty of RAM. Running ./chip takes about 1.9G with my hack. I have 8G RAM on my machine and it is available.

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

    Default Re: slowness QGraphicsView setScene

    Quote Originally Posted by rk123 View Post
    It is slow.
    So what's the backtrace for?

    Anyway, you can make things faster if you disable indexing in the scene. Even in the backtrace you can see there is BSP algorithm involved there. On the other hand bsp indexing shouldn't happen when you set the scene on a view but rather when you add items to the scene...unless GV delays building the index until you access some method that might actually need it. Is there something specific you are doing before calling setScene()?
    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
    Apr 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: slowness QGraphicsView setScene

    Yes, I see the BSP algorithm kick in. I am not sure why. This is coming from QT:
    qt-everywhere-opensource-src-4.6.1/demos/chip
    If you put in the patch I had mentioned, you will see that too.
    Hence, my question of if I am doing something wrong or is it a QT bug.

Similar Threads

  1. QGraphicsView
    By hgedek in forum Qt Programming
    Replies: 1
    Last Post: 17th August 2007, 10:16
  2. QGraphicsView
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 26th July 2007, 09:00
  3. QGraphicsView
    By Shawn in forum Qt Programming
    Replies: 11
    Last Post: 4th June 2007, 15:31
  4. help with QGraphicsView
    By Erlendhg in forum Qt Programming
    Replies: 6
    Last Post: 22nd April 2007, 21:26
  5. Regarding QGraphicsView
    By kiranraj in forum Qt Programming
    Replies: 4
    Last Post: 22nd December 2006, 05:59

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.