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...

    thanks



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

    HTH


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.