Results 1 to 3 of 3

Thread: QGraphicsView, OpenGL and repainting/updating

  1. #1
    Join Date
    Jan 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsView, OpenGL and repainting/updating

    Hello,

    I have a large program. In the past I used Qt3 and a canvas to draw on, on the background a pixmap (or multiple as tiles) and a few thousend lines which could change state (color).

    I moved to Qt4 and changed the canvas to QGraphicsScene and QGraphicsView. I also wanted to get rid of the backgroundpixmap because the quality was ugly when zooming. I use now svg-tiles on a QtGLWidget which zooms very fast and is very nice. The lines are normal QGraphicsLineItems and they can change there color.

    My problem: when the lines change color my CPU usage is about 90%. When a change the QtGLWidget to a QWidget the CPU usage is around 5%. I discoverd that the problem is within the paintEvent. On a QWidget it uses a boundingrect update (and updates only whats changed), but on a QGLWidget it uses a fullviewportupdate and so it renders al the items (few thousand and the background svg).

    I tried to optimize this by using a sort of boundingrectupdate, but what I get is flickering because only a small part of the opengl buffer is filled. I also tried to cache the background, but the rendering into a pixmap was very slow and the overall performance wasn't better.

    What I think is that it can help to draw all the lines with openglstatements in there paint function? Or mayby caching into a QImage and then only draw what's changed?

    Do you have other suggestions?

  2. #2
    Join Date
    Jan 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView, OpenGL and repainting/updating

    Nobody an idea or suggestion?

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView, OpenGL and repainting/updating

    Hi,

    I think that the problem is the overpainting. You have a OpenGL Widget and you overpaint with QPainter.

    Try drawing lines using OpenGL instructions.
    Òscar Llarch i Galán

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.