PDA

View Full Version : draw picture and update



lzpmail
25th August 2011, 11:03
hi, i use double buffer draw wave(not in the paintEvent fun), first i draw wave in a QPixmap, then i use update fun to invoke paintEvent fun draw QPixmap, because invoke update fun more first, so use CPU more, i see the qt helper, the update fun is use to update the widget, but now i do not want to update the widget, i only want update my drawed picture, so please help have any good methods to show the picture in screen. thanks.

high_flyer
25th August 2011, 15:24
but now i do not want to update the widget, i only want update my drawed picture,
you can use update(const QRect & rect ) to update only part of the widget.

lzpmail
25th August 2011, 16:36
yea, i only use update() to update rectangle zone, but because of invoke update() more times(about 25/s), so i want if have more good fun to instead of update().

high_flyer
25th August 2011, 16:56
I don't understand.
The changes you made need to be rendered, and if you call update with the rect to be updated, or another function with the rect to be updated where is the difference?
Both will have to be called every time you need to redraw.

As a side note, calling update at 25 fps, does not mean that the frame gets updated 25 times a second, as update() registers an event, and only if an update is needed, the event will be executed. It therefore likely, specially if you have large portions to draw, that an update() call will NOT issue a new paintEvent().
You might need to call repaint() instead, which is a direct call.
Read the documentation for update() for more details.

lzpmail
26th August 2011, 03:23
yea, you are right, the update() itself have optimization function; in here i think use repaint() not well, this maybe use CPU more.