PDA

View Full Version : Any way to stop QGraphicsview render when zooming or panning ?



tonnot
23rd November 2011, 08:40
When I have a lot of graphic information I'd need a way to stop the drawing in case, in example, I use the wheel to zoom in or out.
If the drawing takes 1 second, and I'm going to do a deep zoom, every update is unusefull.
Now I see how the wheel events are detected when the update is done

Any idea to do this ? Thanks.

gouyoku
23rd November 2011, 11:28
Try updatesEnabled (http://doc.qt.nokia.com/latest/qwidget.html#updatesEnabled-prop).
It may not be what you are looking for tho.

tonnot
23rd November 2011, 13:36
Thanks but ...
I'd need to know when the update starts, how to interrupt it, and when the update ends..
Maybe have I to reimplement paint event for the QGrapchicsView ?
Thanks.

MarekR22
23rd November 2011, 13:58
IMHO first you have to find what is painted so long and fix it.
One of tricks is to cache drawing. Do heavy drawing to QPixmap in some thread and in main thread show this QPixmap.

tonnot
23rd November 2011, 19:24
I'm drawing 100000 rectangles, with indexing.
For Panning maybe useffull what you suggest.
But I keep without knowing the progress of painting... neither stop it.

Nobody else can give me some idea ?

Thanks

d_stranz
23rd November 2011, 19:56
If you are already trapping QWheelEvent events to do the zooming, then set a timer (250 ms or so) in the wheel event handler but do not zoom. If the user is moving the wheel quickly, the timer will be reset before it has a chance to time out. When the user stops moving the wheel, the timer will fire. Then in the timer slot, that's where you do the zoom. In the wheel event handler, you have to keep track of the total wheel movement so you can do a zoom as deep as needed.

tonnot
23rd November 2011, 20:29
Yes, it can be a way. However, in case I want to abort painting have I to investigate paintengine ? (I dont know where to look...)
Also, I'd want to have a way to know the progress. I'm working with big vectorial worlds and need to show when it will be finished .
Thanks d_st

d_stranz
23rd November 2011, 21:13
Also, I'd want to have a way to know the progress. I'm working with big vectorial worlds and need to show when it will be finished .
Then I guess you need to make a custom QGraphicsView class and rewrite the paintEvent() handler. However, interrupting the painting to update a progress indicator might slow things down even more than now.