[Qt-interest] Ignoring double-click in different widgets

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Fri Jul 17 10:31:48 CEST 2009


Hi Everybody, 

I have a large application with many forms in it.  Clicking the OK button on form 1, closes form 1, then opens form 2.  If the user double-clicks the button, then the second click occurs on form2 on whatever control happens to be at the same location.  

The application is used to generate examination questions for students to answer.  So on many forms it is really important that the second click does NOT change the state of the second form. 

Is there an easy way in QApplication to ignore the second click, if it is within the double-click timeout, but when the current widget is different?  

I was thinking of subclassing QApplication, adding event() override, listening for mouse down and maintaining a QPointer to the last clicked widget, and the timestamp.  I am unsure whether discarding the second click might create problems for other situations like when the mouse is grabbed, or menu pop-ups need to be cancelled. 

I am also not sure whether event() is the right method to override in this case. 

Any other suggestions gladly accepted! 

I'm running 4.5.0 on XP sp3, though I am sure the same problem existed in 4.3 & 4.4. 

Tony.





More information about the Qt-interest-old mailing list