我使用QWidget
获得QHBoxLayout
子类的水平布局:
我希望顶部窗口小部件在滑动动画中隐藏/显示。我看过this article,我知道我必须使用QPropertyAnimation
。坦率地说,谷歌的结果不是很好。
有关代码示例的任何建议或可能链接到文章吗?
答案 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();