PDA

View Full Version : update() in QWidget



salmanmanekia
24th July 2008, 14:15
Hi all !
i want to repaint my widget at a signal of a button Clicked but with different picture,
initially the paintEvent should contain a progress bar and after the button is clicked another bar should move in the progress bar showing the progress,so how to repaint/update the paintEvent() but now including the small progress bar moving,should it be done in the same paintEvent function ..!!
i hope it is clear ..

munna
24th July 2008, 14:40
Yes, I think you will need to either call QWidget::update (http://doc.trolltech.com/4.4/qwidget.html#update) or QWidget::repaint (http://doc.trolltech.com/4.4/qwidget.html#repaint) slot. It will in turn trigger paintEvent and then you can repaint your widget accordingly.

salmanmanekia
24th July 2008, 14:45
ya,ya..may be i wasnt able to convey my question properly..anyway i will try again..:)
i know that if you want to repaint the widget then update slot should be called ,but now the picture which i want to draw is different so if i just call the update() the paintEvent() would be called and will draw the same picture which it drew the first time...but this time i want something else (i.e someother picture) as well as the original (i.e first time) picture

jpn
24th July 2008, 20:03
But what is the problem? Just create a function which changes the internal image and calls update(). Or use built-in widgets like QLabel which does it automatically for you.

salmanmanekia
28th July 2008, 08:51
the problem is that that i think all the painting should be done in paintEvent() which can be trigger by update() but now i want the previous and the new picture on the click of button..
i am exactly not sure how to put my code for repainting in paintEvent() because when ever i will call update() ,paintEvent() will do the same work,but now i want different work...

salmanmanekia
28th July 2008, 09:03
ya,the problem is solved ,i just dig into what jpn suggested and it worked..Thanks