Results 1 to 20 of 72

Thread: QGraphicsScene/QGraphicsView performance problems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsScene/QGraphicsView performance problems

    Quote Originally Posted by Gopala Krishna View Post
    Wait a second.. What did you try last time ? Did you implement FieldItem which also draws sub fields and internal shapes or did you use Q*Items for the subfields and internal shapes ?

    If you had implemented FieldItem which draws everything inside it, then the performance you got should be better than that having child items. This is because more the items, more there is strain on bsp indexing and hence the whole mechanism slows down.

    @Wysota: Am i wrong with the above assumption as you suggested the child items option ?
    In the version I referred to (let's call it v1.1) I used the QGraphicsitem subclass FieldItem which draws the field's boundary rectangle, and added it to the scene:
    Qt Code:
    1. class FieldItem : public QGraphicsItem
    2. .
    3. Field = new FieldItem(&outRect,color,&fill);
    4. scene->addItem(Field);
    To copy to clipboard, switch view to plain text mode 
    "color" and "fill" are pointers to the 64-entry colorlist and bool fill parameter.
    Field->paint is responsible for drawing the subfield bounds and the pattern shapes, there are no other GraphicsItems than Fields. The FieldItem object holds a QList with the subfields and pattern shapes, which are added to the Field object by the methods addSubField and addRect:
    Qt Code:
    1. MainWindowImpl::DrawSubFieldBounds() {
    2. .
    3. Field->addSubfield(&sfRect);
    4. .
    5. }
    6. .
    7. MainWindowImpl::DrawRectangle(const QRectF inRectangle) {
    8. .
    9. Field->addRect(&rRect, AreaShot);
    10. .
    11. }
    To copy to clipboard, switch view to plain text mode 
    As a summary, the performance is reasonable at the expense of complexity.

    In the NEXT version (let's call it c1.2) I am using the full parent-child hierarchy with the convenience function QGraphicsRectItem, and ihis is what gives me the poor drawing performance but very light on memory consumprtion.
    I will continue with this by subclassing to Field, SubField, and Shape and include levelOfDetail and as efficient drawing as possible.
    Last edited by bnilsson; 20th January 2008 at 12:13.
    MacOSX user dabbling with Linux and Windows.

Similar Threads

  1. Performance problems with overlapping qgraphicsitems
    By brjames in forum Qt Programming
    Replies: 13
    Last Post: 4th May 2008, 21:42
  2. Poor performance with Qt 4.3 and Microsoft SQL Server
    By Korgen in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2007, 10:28
  3. GraphicsView performance problems
    By Gopala Krishna in forum Qt Programming
    Replies: 79
    Last Post: 8th August 2007, 17:32
  4. Replies: 2
    Last Post: 8th March 2007, 22:22
  5. Replies: 1
    Last Post: 4th October 2006, 16:05

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.