如何动画隐藏/显示QVBoxLayout小部件

时间:2014-06-08 12:32:00

标签: qt animation layout pyqt show-hide

我使用QWidget获得QHBoxLayout子类的水平布局: Layout

我希望顶部窗口小部件在滑动动画中隐藏/显示。我看过this article,我知道我必须使用QPropertyAnimation。坦率地说,谷歌的结果不是很好。

有关代码示例的任何建议或可能链接到文章吗?

1 个答案:

答案 0 :(得分:7)

您可以在动画中更改顶部窗口小部件的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();
相关问题