Results 1 to 3 of 3

Thread: QGraphicsView and QGraphicsScene speeds

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: QGraphicsView and QGraphicsScene speeds

    If you could post your code here, it would be easier to solve your problem. The 40000 chips demo loads 40000 items almost instantly and handles them real time in four views, so unless you are using more than millions of items, it shouldn't be sluggish (when run on a decent machine, of course).

  2. #2
    Join Date
    Feb 2006
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5

    Default Re: QGraphicsView and QGraphicsScene speeds

    Ok I have a dialog with a QGraphicsView inside.
    In my header i have QGraphicsScene *SampleScene;

    Qt Code:
    1. SampleScene = new QGraphicsScene;
    2.  
    3. query.exec( "SELECT x,y FROM samples;" );
    4.  
    5. while( query.next() )
    6. {
    7. ( minX - query.value(0).toDouble() ) * -scaleX, ( maxY - query.value(1).toDouble() ) * scaleY, 5, 5 );
    8.  
    9. SampleScene->addItem(item);
    10. }
    11.  
    12. ui.graphicsView->setRenderHints( QPainter::Antialiasing );
    13. ui.graphicsView->setScene(SampleScene);
    To copy to clipboard, switch view to plain text mode 

    I would prefer dots rather than squares and should be easier to draw. I have tried ui.graphicsView->setUpdatesEnabled(false) which helped slightly but still is very slow. I have also tried QGraphicItemsGroup which I have yet to get working for some reason. I would put the items into a QList of QGraphicItems and then
    Qt Code:
    1. SampleGroup = SampleScene->createItemGroup ( list );
    2. SampleGroup->show();
    To copy to clipboard, switch view to plain text mode 

    But I could never see the points. I have studied the 40000 chips example and have also implemented a custom QGraphicsItem which helped slightly in speed. Everything else looks similar to the chips example but much slower.

Similar Threads

  1. (QT4.2-RC1) QGraphicsScene QGraphicsView QGraphicsItem
    By antonio.r.tome in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 10:56

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.