PDA

View Full Version : QGraphicsPixmapItem::setPixmap() renders very slow



hakiim35
20th August 2011, 17:15
Hi all,
I have been implementing a Pencil Tool (image editing tool) which has a layer structure similar to the one in Adobe PhotoShop. Each layer contains a QPixmap to draw its content. Therefore, I have used QGraphicsView and QGraphicsPixmapItem to implement layer mechanism.
The problem is that, when drawing on high resolution images, rendering is very slow. I have been using QGraphicsPixmapItem::setPixmap() method for pencil , and it tries to draw all the image again and again for every pencil move. I think it is the main reason. Is there any solution to render a smaller portion of a QGraphisPixmapItem::pixmap() instead of updating all the pixmap?
Any idea is welcome.

qlands
22nd August 2011, 09:10
Try by exploring QGraphicsView::ViewportUpdateMode()

If you set the update mode to QGraphicsView::NoViewportUpdate you can control the update process. You can schedule the redraw of an area with QGraphicsScene::update ( const QRectF & rect = QRectF() ) . Also check the void QGraphicsScene::changed ( const QList<QRectF> & region ) [signal].

Carlos.

hakiim35
22nd August 2011, 13:38
Firstly, thanks a lot. However, i think we have dismatched on the issue. I am not considering update of the scene. My question is that how can I operate on few pixels of a QGraphicsPixmapItem's pixmap instead of using setPixmap? In other words, I have a problem on manipulating/changing data of a QGraphicsPixmapItem, not on updating its changed data on the screen.