I have this horizontal layout of a QWidget
subclass using QHBoxLayout
:
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?
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.
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.
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.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With