Results 1 to 2 of 2

Thread: should event filters be used only for debugging

  1. #1
    Join Date
    Nov 2007
    Thanked 1 Time in 1 Post

    Question should event filters be used only for debugging

    is it right to use event filters in the final program. does it slows the execution speed.

  2. #2
    Join Date
    Feb 2006
    Oslo, Norway
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: should event filters be used only for debugging

    I think it's mostly a matter of taste. Overriding an event handler in most cases results to cleaner solution than installing an event filter. Latter might save you from subclassing but the functionality ends up into a "wrong" class.. that is, from the object-oriented point of view. My advise would be to try to avoid event filters as much as possible. Naturally, event filters have their own use cases like handling a group of children or working around limitations in Qt. But in my opinion, you really shouldn't use them as number one approach to implement new functionality.

    Then, about efficiency. Of course, event filters are an "extra step". Every single event received by the target object goes first through all installed filters (unless one of them returns true, which means the event is eaten and event processing stops) and finally reaches its actual target. But it shouldn't have any dramatical slowdown effect unless you do something stupid (read: time consuming) in the event filter function. Notice that one can even install event filters on the whole application object itself.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    babu198649 (22nd November 2007)

Similar Threads

  1. Replies: 1
    Last Post: 16th October 2007, 22:41
  2. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05
  3. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.