Note that there are some explanatory texts on larger screens.

plurals
  1. POSending custom PyQt signals?
    text
    copied!<p>I'm practicing PyQt and (Q)threads by making a simple Twitter client. I have two Qthreads.</p> <ol> <li><p>Main/GUI thread.</p></li> <li><p>Twitter fetch thread - fetches data from Twitter every X minutes.</p></li> </ol> <p>So, every X minutes my Twitter thread downloads a new set of status updates (a Python list). I want to hand this list over to the Main/GUI thread, so that it can update the window with these statuses.</p> <p>I'm assuming that I should be using the signal / slot system to transfer the "statuses" Python list from the Twitter thread, to the Main/GUI thread. So, my question is twofold:</p> <ol> <li><p>How do I send the statuses from the Twitter thread?</p></li> <li><p>How do I receive them in the Main/GUI thread?</p></li> </ol> <p>As far as I can tell, PyQt can by default only send PyQt-objects via signals / slots. I think I'm supposed to somehow register a custom signal which I can then send, but the documentation on this that I've found is very unclear to a newbie like me. I have a PyQt book on order, but it won't arrive in another week, and I don't want to wait until then. :-)</p> <p>I'm using PyQt 4.6-1 on Ubuntu</p> <p><strong>Update:</strong></p> <p>This is an excert from the code that doesn't work. First, I try to "connect" the signal ("newStatuses", a name I just made up) to the function self.update_tweet_list in the Main/GUI thread:</p> <pre><code>QtCore.QObject.connect(self.twit_in, QtCore.SIGNAL("newStatuses (statuses)"), self.update_tweet_list) </code></pre> <p>Then, in the Twitter thread, I do this:</p> <pre><code>self.emit(SIGNAL("newStatuses (statuses)"), statuses) </code></pre> <p>When this line is called, I get the following message:</p> <pre><code>QObject::connect: Cannot queue arguments of type 'statuses' (Make sure 'statuses' is registered using qRegisterMetaType().) </code></pre> <p>I did a search for qRegisterMetaType() but I didn't find anything relating to Python that I could understand.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload