[PyQt] cannot propagate custom events to parent widget
Thomas Espenhain
thomas.espenhain at googlemail.com
Tue Sep 22 20:42:44 BST 2009
Hello,
I'm confused about the event propagation to parent widget with custom
events. The documentation says setting event.ignore() will be pass the
event to the parent widget. It runs great for MouseButtonPress but not
for my custom event (see the following code snipe)
...
# here the custom event
class MsgAOCEvent(QtCore.QEvent):
"""
"""
TYPE = QtCore.QEvent.registerEventType()
#TYPE = 1000
def __init__(self, event_id, data):
QtCore.QEvent.__init__(self, self.TYPE)
self.m_event_id = event_id
self.m_data = data
def event_id(self):
return self.m_event_id
def get_msg_data(self):
return self.m_data
def __del__(self):
print '__del__', self
...
# create the event instance in a deep child widget and post it
# the receiver is the widget itself
# I handle the event in customEvent
class xy(QtGui.QWidget)
def create_event(self):
msg_event = MsgAOCEvent(self.event_id, (self.rec[0], 'test
msg'))
QtCore.QCoreApplication.postEvent(self, msg_event)
def customEvent(self, event):
if event.type() == MsgAOCEvent.TYPE:
event.ignore()
I except after event.ignore() is called it will be passed to parent
and so on until there is a customEvent handler, who can do someting
with it. But I can only trace that event.ignore() is called. After the
call the event will be deleted.
Every hints are welcome!
Thanks a lot!
Thomas
More information about the PyQt
mailing list