I have this horizontal layout of a QWidget
subclass using QHBoxLayout
:
我希望顶部小部件以滑动动画隐藏/显示。我读过了本文 https://qt-project.org/forums/viewthread/8955,我知道我必须使用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();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)