How to temporarily stop draw updates?
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?
Re: How to temporarily stop draw updates?
Code:
setUpdatesEnabled(false);
bigVisualChanges();
setUpdatesEnabled(true);
Re: How to temporarily stop draw updates?
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...
Re: How to temporarily stop draw updates?
Quote:
Originally Posted by gfunk
Thanks! Seems to always be something in Qt that does what you want.
Maybe not always, but most of the times :)
Quote:
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?
Re: How to temporarily stop draw updates?
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.
Re: How to temporarily stop draw updates?
But do you add those widgets when the parent is visible?
Re: How to temporarily stop draw updates?
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...