【发布时间】:2019-04-23 10:20:42
【问题描述】:
我想使用我的 qlabel 作为倒计时。基本上,当倒计时被称为标签更改“3 2 1 begin”时,中间有 1 秒的间隙。
但是,如果我这样做:
def nextSound(self):
self.mainLabel.setText("3")
sleep(1)
self.mainLabel.setText("2")
sleep(1)
self.mainLabel.setText("1")
它只是等到结束而不更新标签。所以我尝试使用QPropertyAnimation:
def nextSound(self):
self.animate = QPropertyAnimation(self.mainLabel,"setText")
self.animate.setDuration(1000)
self.animate.startValue("3")
self.animate.setEndValue("2")
self.animate.start()
但收到此错误:
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'
有什么建议吗?谢谢
【问题讨论】: