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

标签 qt animation layout pyqt show-hide

我有一个 QWidget 的水平布局使用 QHBoxLayout 的子类:
Layout

我希望顶部小部件在滑动动画中隐藏/显示。我已阅读 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/

相关文章:

swift - 如何为 CALayer 从可变起点到给定终点设置动画

Oracle SQL : check individuals in list of values for presence in table

multithreading - QProgressBar 不显示进度?

qt - QML:尝试自动计算字体大小时检测到绑定(bind)循环

c++ - Q标签旋转

android - 类似径向菜单的布局

javascript - iFrame 布局和滚动问题

c++ - 如何在 GUI 更新之间暂停几秒钟?

ios - 在 Swift 的导航栏中动画更改图像

css - 同步 CSS 动画时间(从 到 )