[Qt-interest] Event Filter

phil prentice philp.cheer at talktalk.net
Wed Aug 11 18:01:21 CEST 2010


Hi

  I've been using QT for many years now, but I still consider myself a bit of 
a novice.  I am wondering if its better(more efficient) to use an 
event-filter or to sub-class widgets and catch events that way.

  Basically I have an integer spin-box which increments in blocks of 5.  Only 
5,10,15,....are valid inputs.  I dont want the user to be able to type in 6 
or 7 etc.  I dont know what the standard method is to do this, but my 
thinking is that the user should only be allowed to use the up&down arrows 
and keys to drive it.  So I thought that I might just stop keyboard numeric 
input.  I could sub-class or use an event filter.  Which would be best?

  Secondly I have some other sub-classed frame objects that I need to detect 
if the mouse has been selected inside of them.  I could use the 
mousePressEvent() for those objects
or
I could again use the same event-filter (especially if I already have one 
available from above), but this time catching mouse events.  If I did'nt have 
the event-filter from above I would probably stick with the 
mousePressEvent().

What would you all recommend?

Thanks for any suggestions
Phil



More information about the Qt-interest-old mailing list