我想用我的qlabel作为倒计时。基本上,当倒计时被称为“3,2,1开始”的标签变化,中间有1秒的间隔。在
但是,如果我这样做:
def nextSound(self):
self.mainLabel.setText("3")
sleep(1)
self.mainLabel.setText("2")
sleep(1)
self.mainLabel.setText("1")
它只是简单地等待到结束,而不更新标签。所以我尝试使用QPropertyAnimation
:
但是收到了这个错误:
self.animate = QPropertyAnimation(self.mainLabel,"setText")
TypeError: arguments did not match any overloaded call:
QPropertyAnimation(parent: QObject = None): too many arguments
QPropertyAnimation(QObject, Union[QByteArray, bytes, bytearray], parent: QObject = None): argument 2 has unexpected type 'str'
有什么建议吗?谢谢
QPropertyAnimation
是基于对q-property所取值的插值,当想要使用setText时,我认为最接近的是q-property文本,但是文本不能被插值,因此解决方案是创建一个采用数值的q-property。在另一个最佳选择是使用
^{pr2}$QTimeLine
:相关问题 更多 >
编程相关推荐