PDA

View Full Version : How to temporarily stop draw updates?



gfunk
13th June 2006, 22:48
I have a widget that sets itself up in setupUi(). However, when it sets up, it performs all sorts of drawing in the dialog before it is finally done (resizes itself, adds items, etc), which is quite ugly. Is there a way to halt drawing temporarily, so that the app doesn't go through all this intermediary drawing - so when I re-enable drawing, it looks as if it was drawn cleanly in one step?

I tried to do hide() and show() before and after the setupUi(), but it still has to flicker as it hides and then gets redrawn with show(). Is there a better way?

wysota
13th June 2006, 22:53
setUpdatesEnabled(false);
bigVisualChanges();
setUpdatesEnabled(true);

gfunk
14th June 2006, 00:53
Thanks! Seems to always be something in Qt that does what you want.
The setUpdatesEnabled(false) seems to have gotten rid of perhaps 95% of the flicker; I am still getting tiny bit left though, and I've traced it to inside of setupUi():

vboxLayout->addWidget(treeView);

Not sure how to deal with this one though; I tried explicitly doing setUpdatesEnabled(false) on the treeView, and it did nothing (probably because child widgets are affected by the flag anyway). and vboxLayout being not a widget, so I couldn't call the function on it. What I ended up trying for this was calling setVisible(false) on the parent widget, and that seems to do the trick. Kind of hacky though...

wysota
14th June 2006, 09:01
Thanks! Seems to always be something in Qt that does what you want.
Maybe not always, but most of the times :)


The setUpdatesEnabled(false) seems to have gotten rid of perhaps 95% of the flicker; I am still getting tiny bit left though, and I've traced it to inside of setupUi():

vboxLayout->addWidget(treeView);

Not sure how to deal with this one though; I tried explicitly doing setUpdatesEnabled(false) on the treeView, and it did nothing (probably because child widgets are affected by the flag anyway). and vboxLayout being not a widget, so I couldn't call the function on it. What I ended up trying for this was calling setVisible(false) on the parent widget, and that seems to do the trick. Kind of hacky though...


Do you have anything unusual in the tree view? What causes the flicker?

gfunk
14th June 2006, 09:48
Nothing special about the treeView, just a regular QTreeWidget. There are a couple other widgets added to this vboxLayout as well, I'm not sure why they don't trigger the flicker. I will probably have to step through some more code to try to find what other differences it has.

wysota
14th June 2006, 09:56
But do you add those widgets when the parent is visible?

gfunk
14th June 2006, 18:37
Yes, the flicker during the addWidget() call would occur while the parent was visible. Is that a no-no? I guess I assumed that a setupUi call would implicitly disable draw updates until it was completely done with setup. So, maybe calling setVisible isn't such a hack after all...