installeventfilter

L

luca72

helo i have this form how i can install the event filter:
Class Form(QWidget, Ui_Form):
"""
Class documentation goes here.
"""
def __init__(self, parent = None):
"""
Constructor
"""
QWidget.__init__(self, parent)
self.setupUi(self)

Thanks
 
P

Phil Thompson

Le 11/10/11 10:39, luca72 a �crit�:
helo i have this form how i can install the event filter:
Class Form(QWidget, Ui_Form):
"""
Class documentation goes here.
"""
def __init__(self, parent = None):
"""
Constructor
"""
QWidget.__init__(self, parent)
self.setupUi(self)

Thanks

MainWindow.eventFilter = self.event_filter

...

def event_filter(self, object, event):
������� # example: window is resized
������� if event.type() == 14:
����������� resize()
����������� return True

In your case, 'MainWindow' seems to be 'parent'

Monkey patching is not a good idea.

class EventFilter(QObject):
def eventFilter(self, object, event):
# example: window is resized
if event.type() == QEvent.Resize:
object.resize()
return True

event_filter = EventFilter()
form = Form()

form.installEventFilter(event_filter)

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,212
Latest member
BrennaCaba

Latest Threads

Top