python Qlabel 不显示图像

python Qlabel doesnt display images

我尝试每 5 秒动态更改图像,第一次显示正确,之后什么都不显示,这是我的代码,

 def imageSelect(self):

    name = self.selectImageFromDb()#Fetch image name from database one by one

    self.pic.clear()
    myPixmap = QtGui.QPixmap(_fromUtf8(path + "images/" + name))

    self.pic.setPixmap(myPixmap)

    self.pic.show()

    threading.Timer(3, self.imageSelect).start()`

如果我坐这条线

threading.Timer(3, self.imageSelect).start()

在函数 imageSelect() 之外,我可以重现此行为。我收到错误消息:

QObject::startTimer: Timers can only be used with threads started with QThread

所以我改用了QTimer(成功):

self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.imageSelect)
self.timer.start(1000)            # interval in milliseconds