Do I need to call installEventFilter(this)?
-
Will the filter for this install itself? I tried it, it works in both cases, but I couldn't find any information about self-setting of the filter in the documentation.
class MyClass : public QObject { Q_OBJECT MyClass() { installEventFilter(this); //Do I need this? } protected: bool eventFilter(QObject*, QEvent*) override { } };
-
@raven-worx
That is, installEventFilter allows you to handle events before they arrive in the overridden eventFilter class method? -
Will the filter for this install itself? I tried it, it works in both cases, but I couldn't find any information about self-setting of the filter in the documentation.
class MyClass : public QObject { Q_OBJECT MyClass() { installEventFilter(this); //Do I need this? } protected: bool eventFilter(QObject*, QEvent*) override { } };
-
@JobRecrd
Yes it will "install for itself" with this code. "Do I need this?" You do not need it, but you can do it if you want to filter yourself. -
@JonB
Can you explain why it will be installed for itself? I don't really understand what will change when adding installEventFilter in this case.@JobRecrd
you could inspect all events before they are actually processed in the event handlers.
Buts its better practice to override the corresponding event handlers or even the generic event() method instead of doing it this way. -
@JobRecrd
you could inspect all events before they are actually processed in the event handlers.
Buts its better practice to override the corresponding event handlers or even the generic event() method instead of doing it this way.@raven-worx
That is, installEventFilter allows you to handle events before they arrive in the overridden eventFilter class method? -
@raven-worx
That is, installEventFilter allows you to handle events before they arrive in the overridden eventFilter class method?