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

Generic event filter creation.

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P4: Low
    • None
    • None
    • Core: Object Model
    • 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

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

          Activity

            People

              Unassigned Unassigned
              zekses Nikolai
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes