Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Animated geometry in layout flickering
Rostislav last edited by
Hi Qt community,
I seem to have a problem of making a flicker free geometry animation when my widget is embedded into a layout.
The basic idea is that I want multiple checkable buttons in toolbar which when clicked discover some other buttons hidden under them.
To achieve that I do the following:
Create horizontal layout
Add the main button
Add a "PopupWidget"
The PopupWidget itself is a class inspired by ctkPopupWidget
My implementation subclasses QStackedWidget with 2 widgets
- A QWidget with zero-margin vertical layout, which contains a QFrame where all the child buttons would be put into
- A QWidget with zero-margin vertical layout, which contains a QLabel
When it is requested to close, a pixmap is created for QLabel using QWidget::grab() on first page in the PopupWidget. Then, the page of QStackedWidget is changed to show the QLabel. Finally an animation is set up to reduce geometry from the starting geometry to the one with zero width. Geometry is not animated directly, but rather I have a property in PopupWidget which is animated and the write function for this property uses setFixedSize() so that the layout is updated.
However, when the animation is run, the checkable button flickers. I watched at screen grab frame by frame and the button seems to move by a couple of pixels or its size is changed (even though I set its policy to Fixed).
This flickering doesn't happen every time, but it is very annoying.
Any ideas about this?
short video showing the problem: https://www.dropbox.com/s/9u0xywpik1bw1ww/Popup_Widget.mp4?dl=0
the zipped source code: https://www.dropbox.com/s/flibxta4v3io8fl/PopupWidget.zip?dl=0