[PyKDE] QtEvent

Carles Pina i Estany carles at pina.cat
Sat Oct 28 09:58:02 BST 2006

Hello again!

On Oct/27/2006, Carles Pina i Estany wrote:

> In the previous application, to communicate from one thread to another one I
> have:
> def sendInformation(id,s,gui):
>         event = QEvent(id)
>         event.setData(s)
>         QApplication.postEvent(gui,event)

> In the new Qt version it seems that I have to subclass from QEvent to do the
> same. I have done some tests without good result. 

Now I have done it. I send my solution here for information for newcommers of
for if experts has better way to do it.

In my thread:

#gui: main widget
#id: message number
#s: message contents
def sendInformation(id,s,gui):

In QMainWindow constructor I have added:

And then this method:
        def eventFilter(self,object,event):
                if (event.type() == QtCore.QEvent.Type(QtCore.QEvent.User+1)):
                        print "Here"
                        return True

                return QtGui.QWidget.eventFilter(self,object,event);


Carles Pina i Estany		GPG id: 0x8CBDAE64
	http://pinux.info	Manresa - Barcelona

More information about the PyQt mailing list