Details
-
Suggestion
-
Resolution: Unresolved
-
P4: Low
-
None
-
None
-
None
Description
Having to subclass QObject each time an event filter is needed is, imo, completely unnecessary. I suggest making it possible to create one directly from function object (aka std::function<bool(QObject*, QEvent*)>).
The user will then just instantiate a generic with a functor of his choice(even lamda possible) and slap it wherever he needs, no subclassing necessary. It will even have an added benefit of binding any data necessary to and external function prior to passing it to generic.
Below is a wrapper I use for this task in my code as an example.
https://github.com/Zeks/douml/blob/catalog/src/Libs/L_UniversalModels/include/genericeventfilter.h
https://github.com/Zeks/douml/blob/catalog/src/Libs/L_UniversalModels/src/genericeventfilter.cpp
Attachments
Issue Links
- duplicates
-
QTBUG-91684 Lambda / template eventfilter support
- Reported