On Sat, 19 Mar 2011 10:05:31 +0000, Phil Thompson <[email protected]> wrote: > On Fri, 18 Mar 2011 21:44:06 -0400, "Brett Stottlemyer" > <[email protected]> wrote: >> I'm trying to process WM_INPUT in an application. I know that in Qt you >> need to use QAbstractEventDispatcher and setEventFilter to get the >> messages. >> However, when I try to use setEventFilter, I get an Attribute error, >> 'QAbstractEventDispatcher' object has no attribute 'setEventFilter'. >> >> An example script is pretty simple and should allow the error to be >> reproduced: >> >> import sys >> from PyQt4.QtCore import * >> from PyQt4.QtGui import * >> >> def myEventFilter(message): >> print message.message >> return True, id(message) >> >> class QApp(QApplication): >> def __init__(self, *args): >> super(QApp, self).__init__(*args) >> > QAbstractEventDispatcher.instance().setEventFilter(myEventFilter) >> >> if __name__ == '__main__': >> app = QApp(sys.argv) >> widget = QPushButton("Push me") >> widget.show() >> sys.exit(app.exec_()) >> >> This is with Python 2.7 and PyQt 4.8.3 on a Win7 box. >> >> Any suggestions? > > It's not implemented because the message itself is platform specific and > not part of Qt. That said there is partial support for XEvent to allow you > use the struct module to unpack it, so I could do something similar for > NSEvent (MSG is already supported). That would probably be enough to make > setEventFilter() useful. > > ...watch this space.
Support for setEventFilter() and filterEvent() will be in tonight's snapshot. I confess that I haven't tried to build it on Windows (there is some Windows specific code). Support is limited - you can only set a filter for one dispatcher at a time. Phil _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
