How to animate the hide / show of a QVBoxLayout widget

I have this horizontal subclass layout QWidgetusing QHBoxLayout: Layout

I would like the top widget to be hidden / shown in a rolling animation. I read this article and I know what I need to use QPropertyAnimation. Honestly, Google is not getting a good result.

Any suggestion for sample code, or perhaps a link to an article?

+4
source share
1 answer

You can change the property of the maximumHeighttop widget in the animation.

To hide the top widget:

QPropertyAnimation *animation = new QPropertyAnimation(ui->topWidget, "maximumHeight");
animation->setDuration(1000);
animation->setStartValue(500);
animation->setEndValue(0);

animation->start();

To show the top widget:

QPropertyAnimation *animation = new QPropertyAnimation(ui->topWidget, "maximumHeight");
animation->setDuration(1000);
animation->setStartValue(0);
animation->setEndValue(500);

animation->start();
+6
source

Source: https://habr.com/ru/post/1543745/


All Articles