[PyKDE] Use of postEvent

Phil Thompson phil at river-bank.demon.co.uk
Thu Mar 21 10:24:32 GMT 2002

greg Landrum wrote:
> (apologies if this arrives a second time... I used the wrong return address
> on the last one so it got held up by mailman)
> [System details: RH linux 7.1 kernel 2.4.2-2smp, Python 2.1.1, Qt 3.0.2,
> PyQT/Sip-3.1rc2]
> I just started using PyQt recently (I'm kind of a refugee from wxPython)
> and I'm really impressed.  Qt itself is pretty nice and PyQt really adds to
> it.  Thanks for the hard work.
> On to my question/problem.
> I'd like to add some RPC control to my application.  So I've got a PyQt
> application running in one thread and an xmlrpc server running in
> another.  Whenever the xmlrpc server gets a call, it constructs a special
> event and fires that into the event queue for the main app using
> postEvent.   I've built a similar system for wxPython to do this, so the
> xmlrpc/multithreading/event queue bits were pretty straightforward to get
> working.  (Well, kind of, getting PyQt compiled with thread support fully
> enabled wasn't totally straightforward, more on this below).  Things now
> more or less work, but there's a snag: my event doesn't get processed by
> the application until I do something like move the mouse from one window to
> another or change focus or something like that.  Needless to say, this
> makes the RPC server somewhat less useful.  :-S
> Any clues as to why this might be the case?

I assume you are using QThread.postEvent() (rather than
QApplication.postEvent()). Can you try the attached patch? It might not
work, but it's the only obvious thing I can try from a PyQt point of

> An aside about building PyQt with thread support:
> I have a qt build with multi-threading enabled, but I had to screw around a
> bit with the PyQt and sip configure scripts to get them to enable thread
> support.  I know very little about configure, but it looks like the tests
> at around line  9440 in the sip configure script should have the "Regular
> Qt" case *after* the multithreaded and embedded cases.  Similarly, at line
> 8899 in the configure script for PyQt, I had to move the 'qt' option to
> after 'qt-mt' and 'qte'.

So you have both qt and qt-mt installed at the same time in the same
directory? Is this something that distros do? If so I guess it really
needs to be a configuration option, but I've swapped the order for now
as that is probably right for most people.

-------------- next part --------------
--- sipqtQThread.cpp.orig	Mon Mar 18 10:49:50 2002
+++ sipqtQThread.cpp	Thu Mar 21 09:08:04 2002
@@ -180,9 +180,11 @@
 		QObject * a0;
 		QEvent * a1;
-		if (sipParseArgs(&sipArgsParsed,sipArgs,"J0J0",sipClass_QObject,&a0,sipClass_QEvent,&a1))
+		if (sipParseArgs(&sipArgsParsed,sipArgs,"J0J2",sipClass_QObject,&a0,sipClass_QEvent,&a1))
+			sipReleaseLock();
+			sipAcquireLock();
 			return Py_None;

More information about the PyQt mailing list