Results 1 to 9 of 9

Thread: Performance trouble in Graphics View

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Performance trouble in Graphics View

    Hi again,

    I'm about to finish my project but I'm currently suffering from the performance. My cursor barely moves(very slow) on the scene. I want you to let me know what possible problem that I'm facing now. Any little idea can be significantly change the performance so please share.

    I have number of graphics item inside other graphics item which are all inside the scene and view as usual. I mostly reimplemented boundingRect() and shape() methods together to increase performance when necessary.

    If you can't figure out what's I'm saying above, please let me know again.

    Cheers, Zeck.

  2. #2
    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: Performance trouble in Graphics View

    Please provide more information - what optimizations you already enabled, what items are we talking about, what are their shapes, how many of them are there, etc.
    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
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Performance trouble in Graphics View

    Sure,

    think you have a graphicsitems which resides in a graphics item group. they are all in scene and view.

    Now, I reimplement shape() in addition to boundingRect() in order to optimize mouse operations. I already reimplemented boundingRect() in the item group, scene and view as well as i'm supposed to do.

    My graphics item are movable. I did drag-drop issue by using itemChange(). I mean when position changes by the mouse, itemChange() method deals with the necessary things( i.e. changing core data) in itself. I suspect there should be something like recursion between itemChange() and paint(). I'm now looking for it.

    By the way shapes are polygons that excellently covers around items.

  4. #4
    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: Performance trouble in Graphics View

    What's the exact implementation of boundingRect() and shape()? Do you cache items? What's the bottle-neck according to the profiler?
    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
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Performance trouble in Graphics View

    I'm not allowed to provide code. Sorry for this first of all.

    As I said before, in shape() I return a polygon which exactly covers around my item. In boundingRect() I just return a QRect with arbitrary sizes like;

    Qt Code:
    1. return new QRect(-1000, -1000, 2000, 2000);
    To copy to clipboard, switch view to plain text mode 

  6. #6
    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: Performance trouble in Graphics View

    Cache as much data as possible. Find the bottleneck using a profiler and eliminate it.
    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. #7
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Performance trouble in Graphics View

    Hi,

    Can you explain a bit more about caching if you don't mind ?.

  8. #8
    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: Performance trouble in Graphics View

    Cache the data - don't create instances of QRectF and QPainterPath on every call to boundingRect() and shape(). Also cache the items. And please use a profiler instead of just guessing.
    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.


  9. #9
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Performance trouble in Graphics View

    Have you tried to use OpenGL as the viewport of your QGraphicsView?
    It may increase performance.

    It is so easy as :
    Qt Code:
    1. setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Graphics View and the Pixmap
    By spawn9997 in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2009, 22:12
  2. Replies: 3
    Last Post: 26th May 2009, 21:12
  3. Graphics View Panning ,zooming
    By linuxdev in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2008, 07:17
  4. Replies: 4
    Last Post: 5th August 2008, 19:55
  5. Graphics View Event Propagation
    By pherthyl in forum Qt Programming
    Replies: 10
    Last Post: 3rd July 2008, 10:39

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.