As a home developer this is my first post to any development forum. Although I am using Python this was the best QT forum I could find so apologies : but my question is probably applicable to c++ as well.

I think I must be missing something with animations.

I am trying to use a QtWidgets.QLabel (lblPhotoDisplay) containing an image to create a simple animated slide show using fade/unfade methods (see below). Chaining the methods using the animation.finished trigger seemed the obvious (to me at least) way to achieve this.

I am calling the fade method from a displayImage method and using the animation.finished trigger to change the image then call the unfade method which unfades with its animation.finshed submitting a job to change the image again at a specified time.

My problem is that everything works OK first time the fade animation is called. Subsequent calls fail to trigger fade animation.finished.

What am I missing -- do animation not chain like this?



def fade(self):
self.effect = QGraphicsOpacityEffect()
self.lblPhotoDisplay.setGraphicsEffect(self.effect )

self.animation = QtCore.QPropertyAnimation(self.effect, b"opacity")
self.animation.setDuration(1000)
self.animation.setStartValue(1)
self.animation.setEndValue(0)
self.animation.finished.connect(self.changeImage)
self.animation.start()

def unfade(self):
self.effect = QGraphicsOpacityEffect()
self.lblPhotoDisplay.setGraphicsEffect(self.effect )

self.animation = QtCore.QPropertyAnimation(self.effect, b"opacity")
self.animation.setDuration(1000)
self.animation.setStartValue(0)
self.animation.setEndValue(1)
self.animation.finished.connect(self.nextImage)
self.animation.start()