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

Christopher Rasch-Olsen Raa christopher at technophile.info
Fri Jul 17 13:43:53 CEST 2009


 Fredag 17 juli 2009 13:45:22 skrev John McClurkin :
> Tony Rietwyk wrote:
> > 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!
>
> How about in the slot called when the OK button is clicked, you close
> the form after a short time. Perhaps call QTimer::singleShot() and close
> the form in the slot sent to QTimer.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

You could also wait a given amount of milliseconds (that span longer than 
interval between mouseclicks) before you enable buttons on form number two. 

--
Christopher




More information about the Qt-interest-old mailing list