Results 1 to 5 of 5

Thread: QGraphicView Optimizing cpu

  1. #1
    Join Date
    Jul 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default QGraphicView Optimizing cpu

    hello

    I have edit a Qt application using QGraphicsView / QGraphicScene and it's consume a lot of cpu (60%).

    my classes are a custom QGraphicsView / QGraphicScene and Reimplemented
    Qt Code:
    1. QGraphicsView::drawforeground(QPainter* ptPainter, const QRectF& tRectToDraw)
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. QGraphicsView::drawbackground(QPainter* ptPainter, const QRectF& tRectToDraw)
    To copy to clipboard, switch view to plain text mode 
    used for drawing some statics items.

    and i think thats methods causes the big consume of cpu.
    my question is how can i optimise my application and reducing cpu consume.

    thanx in advance.

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

    Default Re: QGraphicView Optimizing cpu

    Without seeing any actual code it is hard to suggest anything.
    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
    Jul 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: QGraphicView Optimizing cpu

    this is the sources of qgraphicsvew and qgraphicscene attached.
    scene.cppscene.hgraphicview.hsource.zip

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

    Default Re: QGraphicView Optimizing cpu

    First of all I don't think you should be calling QGraphicsView::drawForeground() from within drawBackground(). Second of all try reducing the amount of calculations done in drawBackground() and certainly do not create any items in drawForeground(). Apart from that, since you are caching the background, drawBackground() should not be very expensive as it is, unless you are changing the scene size (or zooming in and out) frequently. Then caching the background will slow down your app instead of speeding it up. In that case try removing the gradient from your background and see if it helps anything.
    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
    Jul 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: QGraphicView Optimizing cpu

    thanx wysota

Similar Threads

  1. How to use QGraphicView?
    By karthic in forum Newbie
    Replies: 12
    Last Post: 27th April 2012, 08:06
  2. Need help in optimizing a drawing code ...
    By ahmadka in forum Qt Programming
    Replies: 10
    Last Post: 24th June 2010, 13:45
  3. my QGraphicView problem
    By irmakci in forum Qt Programming
    Replies: 3
    Last Post: 19th July 2008, 18:40
  4. Optimizing redrawing in the scene
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 28th November 2007, 17:00
  5. Optimizing filterAcceptsRow() to filter a tree
    By vfernandez in forum Qt Programming
    Replies: 1
    Last Post: 4th January 2007, 12:50

Tags for this Thread

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.