[PyQt] QMovie start/stop from a different thread

tom tomschuring at gmail.com
Thu Nov 26 00:07:37 GMT 2009


thanks david,

i was looking for a code example of that. all the examples i found are using
existing 'events' like clicked() of a button.

figured it out in the end so for others looking for something similar:

i ended up creating a function like:

def startMyMove(self):
     self.movie.setPaused(False)

def stopMyMove(self):
     self.movie.setPaused(False)

linking them like

        self.connect(self, QtCore.SIGNAL("startMyMovie()"),
self. startMyMovie )
        self.connect(self, QtCore.SIGNAL("stopMyMovie()"),
self. stopMyMovie )

in the constructor

and when i want it to start or stop i call :

self.emit(QtCore.SIGNAL("startMyMovie()") )
or
self.emit(QtCore.SIGNAL("stopMyMovie()") )

from within the thread

seems to work

thanks all !!

2009/11/26 David Boddie <david at boddie.org.uk>

> On Wed, 25 Nov 2009 16:35:28 +1100, tom wrote:
>
> > i create a QMovie in the main thread :
> >
> >         self.movie = QMovie("images\whitephone-animation.mng",
> > QByteArray(), self)
> >         self.movie.setCacheMode(QMovie.CacheAll)
> >         self.movie.setSpeed(100)
> >         self.movie_canvas.setMovie(self.movie)
>
> [...]
>
> > can i call the start / stop slots from within that different thread, and
> > how would i do that ?
>
> Connect signals to the movie's start() and stop() slots, and emit them when
> you need to start or stop it.
>
> David
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20091126/f92c1f44/attachment-0001.html


More information about the PyQt mailing list