PyQt5 QPropertyAnimation finished() how to connect

Dsa*_*ash 0 python qt pyqt pyqt5

In essence, i'm trying to close a window after the animation completes. In all the documentation and examples i've looked at, they are either in:

  • C++
  • vague "method definitions"
  • Old style slots and connectors

how do i access the finished() that gets 'supposedly' called when the animation finishes?

self.anim = QtCore.QPropertyAnimation(window, b"windowOpacity"
self.anim.setStartValue(1)
self.anim.setEndValue(0)
self.anim.setDuration(3000)
#self.anim.finished.connect() does not exist
#QtCore.QObject.connect(stuff) is deprecated
#self.anim.finished(window.destroy) destroys window immediately
Run Code Online (Sandbox Code Playgroud)

in all the examples i am reading, they use the first commented out method, but the compiler complains about 'finished' not having a 'connect()' method

Dsa*_*ash 6

我用finished错了,应该如何使用:

self.anim.finished.connect(self.someMethod)
def someMethod(self):
window.destroy
Run Code Online (Sandbox Code Playgroud)

我希望这对将来的人有帮助。