[PyQt] QPropertyAnimation called from another thread

David Boddie david at boddie.org.uk
Sat Aug 14 02:35:49 BST 2010


On Sat Aug 14 01:23:00 BST 2010, Martin Airs wrote:

> Well I finally got it working, I just created a QObject to emit a signal 
> passing the nick and ip as arguments
>
> class emitter(QtCore.QObject):
>      def __init__(self):
>          QtCore.QObject.__init__(self)
>      def send(self, nick, ip):
>          self.emit(QtCore.SIGNAL("mysig(QString,QString)"), nick, ip)
>
> then I connected the signal to myapp.creatUserTile with..
>
> QtCore.QObject.connect(myemitter, 
> QtCore.SIGNAL("mysig(QString,QString)"), myapp.createUserTile)

In theory, it should have been possible to emit a signal from the thread
itself, connecting it using

QtCore.QObject.connect(myclient, 
QtCore.SIGNAL("mysig(QString,QString)"), myapp.createUserTile)

because QThread is itself a QObject subclass.

> then in the Client thread I can...
>
> myemitter.send(nick,ip)
>
> that enabled me to start the animation from within the parent thread
>
> sorry is this list meant for end user support, or is it more for devs
> and internal matters?

Both, but it sometimes takes people time to respond to questions on certain
subjects. I would have responded earlier today, but was busy with work
stuff, and probably would have just referred you to

  http://www.diotavelli.net/PyQtWiki/Threading,_Signals_and_Slots

An article recently posted on a blog has suggested that doing this kind of
thing with QThread isn't quite using it in the way it was designed to be
used. Maybe I'll rewrite this example at some point.

David


More information about the PyQt mailing list