[PyKDE] postEvent problem

Aurélien Gâteau aurelien at dental-on-line.fr
Tue Oct 14 10:59:01 BST 2003

Le Lundi 13 Octobre 2003 17:57, Aurélien Gâteau a écrit :
> Hello again, list
> I have another problem: the code I want to bind with work like this:
> In my C++ code, I run a thread which is monitoring various things. When
> interesting stuff happens, the thread notify a listener about it using
> QApplication::postEvent(myListener, myEvent).
> In my C++ test program, all works well, but in py Python test program, the
> posted event never reaches the listener. As anyone encountered the same
> problem?

Some more informations: the C++ code (libdolsphinx) I wrote is a library 
listening words from a voice recognition tool. Inside libdolsphinx, there is 
a Qt thread which is waiting for words and post Qt events for them. The 
(simplified) code looks like this:

namespace DolSphinx {
static Listener* sListener;

void setListener(Listener* listener) {

class ListenThread : public QThread {
  void run() {
    while(true) {
      if (wordHeard) {
        if (sListener) {
          QApplication::postEvent(sListener, new DolSphinxWordHeard(word));




sListener is my DolSphinx::Listener object. The test code starts the thread 
loop, then calls DolSphinx::setListener with a DolSphinx::Listener object. 
The Listener object receives the posted event in its eventFilter() method, and 
emit Qt signals.
In my C++ test code, the Listener object receives correctly the posted event. 
In the Python one, it doesn't.

Tell me if you need more information.


More information about the PyQt mailing list