PDA

View Full Version : Question regarding how to paint after zoom.



JonathanForQT4
26th January 2007, 14:35
Hello all, I am using QT4.2 for the first time and I am currently writing a program that can zoom in and out of "background widget". "background widget" is set as the primary widget for a scroll area so when zoomed in you can still scroll around.

My question is as follows: should I be using update() or repaint() to call paintEvent within "background widget" after the zoomin calculation is done?

In this example repaint() is used: http://qt4.digitalfanatics.org/articles/zoomer.html
but on the trolltech website they always use update() in their examples and in the qwidget documentation it recommends to use update unless it's animation.

I have tried to use update() but the following error happens: when I use my rubberband to zoom....the contents within the rubberband are the colour of where the rubberband was started......I update the rubberband dimensions in the mouse events.
When using repaint() this doesn't happen....and I am confused why this makes a difference?


My second question is...I want to make a crosshairs over the entire viewport area to show an updating scale for each time you zoom in. I have tried to put this into paintevent of "background widget", but there are problems when scrolling using the scrollbars(the transparent crosshairs don't get wiped over....but stay creating a smear effect). Should I be writing this somewhere else?

Any help would be much appreciated, thank you!!!

Jonathan

e8johan
26th January 2007, 15:00
I wrote the article you refer to. If Trolltech says update, do use update.

wysota
26th January 2007, 15:34
update() schedules a paintEvent (in short uses postEvent) whereas repaint() repaints instantly (in short uses sendEvent). You should always use update() unless you have a good reason to use repaint().