Qt World Summit: Register Today!

Help with QAbstractNativeEventFilter

  • i need to recieve windows native events in a MYCLASS that is instantiated in a QWidget..... i am deriving MYCLASS from QAbstractNativeEventFilter and overriding the virtual nativeEventFIlter . and that is as far as i get.....the program compiles but no native events are received

    it says in the documentation that i need to install the filter on the application object using the constructor....but there seems to be no constructor for this abstract class.....the documentation is quite minimal, could someone please explain the correct method of using this abstract class...


  • Hi
    Within your main window class declare the following (or similar)
    class MyNativeEventFilter: public QAbstractNativeEventFilter
    virtual bool nativeEventFilter(const QByteArray &eventType, void message, long )
    msg = (MSG
    if(msg->message == WM_SYSCOMMAND &&
    (0xfff0 & msg->wParam) == SC_CONTEXTHELP) {
    return false;
    Then in the constructor of the main window class install the event filter -
    QApplication::instance()->installNativeEventFilter(new MyNativeEventFilter());


Log in to reply