Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-29731

Generic event filter creation.

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • Icon: P4: Low P4: Low
    • None
    • None
    • Core: Object Model
    • None

      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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            cnn Qt Core & Network
            zekses Nikolai
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes