Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to animate hiding/showing of a QVBoxLayout widget

I have this horizontal layout of a QWidget subclass using QHBoxLayout: Layout

I would like the top widget to hide/show in sliding animation. I have read this article, and I know that I have to use QPropertyAnimation. Frankly, not a good Google result come up.

Any suggestion for code example or maybe link to an article?

like image 390
swdev Avatar asked Jun 08 '14 12:06

swdev


People also ask

How do I hide and show widgets with animation in flutter?

Flutter provides AnimatedOpacity Widget to change the opacity of the widget when show and hide in progress. It will linearly change the opacity and you can change the curve (how the animation should happen) by setting values like bounceIn, easeInOut etc. The main property which you need to set is opacity.

How do you animate a view?

Create ImageView in the activity_main. xml along with buttons that will add animation to the view. Navigate to the app > res > layout > activity_main. xml.

What is Animatelayoutchanges?

Android offers pre-loaded animation that the system runs each time you make a change to the layout. All you need to do is set an attribute in the layout to tell the Android system to animate these layout changes, and system-default animations are carried out for you.


1 Answers

You can change the maximumHeight property of the top widget in an animation.

For hiding the top widget :

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

animation->start();

for showing the top widget :

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

animation->start();
like image 95
Nejat Avatar answered Oct 05 '22 06:10

Nejat