flickering when hiding and showing widget
-
I put a button and label in a widget, when I set visible to the widget, I will got same problem with this https://stackoverflow.com/questions/37640286/avoid-flickering-when-hiding-and-showing-widget.
It is have better way to solve this problem?qt version : 5.9.5
-
@OtisLin I don't know what your use case exactly is, but did you consider to use https://doc.qt.io/qt-5/qstackedwidget.html ?
-
Thanks your reply.
My question like this. Button_A will set area C visible false. add Button_B will set area C visible true.
When the area C hidding and showing some times have flickering.It's look like layout problem. But still not found the key point. Maybe the QStackedWidget is the best way.
-
How is the connection between your buttons and the slots made ? This kind of issue often arises when there are several updates instead of one, which may be the case if A and B are grouped to be mutually exclusive. Do you use QPushButton::pressed or QPushButton::toggled ? It might be just because you simplified your issue to provide a minimal exemple, but it looks like you are using two buttons when you only need one (with a checked/unchecked state).
Can you put some debug code in your "setVisible" slot, to check if it's called only once each time ?
Does you still have that flickering is you put a breakpoint in the setVisible slot ?Last check : how is your layout made ? I guess C is a large widget that is inside a QVBoxLayout ? What happens when C is not visible ? Do A and B get lower, or is there a large bottom margin ? You may need a addStrech() at the end of your layout, if it's not already there.