C++ (Qt)bool MyForm::eventFilter(QObject *obj, QEvent *event){ switch (event->type()) { case 8: // QEvent::FocusIn: break; case 6: // QEvent::KeyPress: break; case 7: // QEvent::KeyRelease: break; default:; } // standard event processing return QWidget::eventFilter(obj, event);}
C++ (Qt)#if defined(_XLIB_H_) // crude hack, but...#error "cannot include <X11/Xlib.h> before this file"#endif ... // rename a couple of X defines to get rid of name clashes// resolve the conflict between X11's FocusIn and QEvent::FocusInenum { XFocusOut = FocusOut, XFocusIn = FocusIn, XKeyPress = KeyPress, XKeyRelease = KeyRelease, XNone = None, XRevertToParent = RevertToParent, XGrayScale = GrayScale, XCursorShape = CursorShape};#undef FocusOut#undef FocusIn#undef KeyPress#undef KeyRelease#undef None#undef RevertToParent#undef GrayScale#undef CursorShape