[英]Qt C++ Slowly move QListWidget
我有QListWidget,我需要从一个点移动到另一个点,但是它必须很慢,就像动画一样。 你能帮我吗
您需要为此使用Qt Animation框架 。 有许多示例可用,因此您应该阅读它。
通过使QListWidget
geometry属性动画,可以使用QPropertyAnimation类完成您想做的事情:
QPropertyAnimation animation(&lstWidget, "geometry"); //animate geometry property
animation.setDuration(5000); // 5 seconds
animation.setStartValue(QRect(50, 50, 100, 100)); // start value for geometry property
animation.setEndValue(QRect(300, 300, 100, 100)); // end value for geometry property
animation.start();
这将从(50,50)小部件移动到(300,300)。 您可以通过从lstWidget
读取geometry
属性以从当前位置开始移动等来设置起始值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.