我有一个 QWidget
的水平布局使用 QHBoxLayout
的子类:
我希望顶部小部件在滑动动画中隐藏/显示。我已阅读 this article ,我知道我必须使用 QPropertyAnimation
.坦率地说,没有一个好的谷歌结果出现。
对代码示例或文章链接有什么建议吗?
最佳答案
您可以更改 maximumHeight
动画中顶部小部件的属性。
隐藏顶部小部件:
QPropertyAnimation *animation = new QPropertyAnimation(ui->topWidget, "maximumHeight");
animation->setDuration(1000);
animation->setStartValue(500);
animation->setEndValue(0);
animation->start();
用于显示顶部小部件:
QPropertyAnimation *animation = new QPropertyAnimation(ui->topWidget, "maximumHeight");
animation->setDuration(1000);
animation->setStartValue(0);
animation->setEndValue(500);
animation->start();
关于qt - 如何动画隐藏/显示 QVBoxLayout 小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24106177/