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

Arnold Krille arnold at arnoldarts.de
Fri Jul 17 20:02:50 CEST 2009


Hi,

this time I think I have the right thread...

On Friday 17 July 2009 10:31:48 Tony Rietwyk wrote:
> 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!

First advice: Teach your users not to double-click.

Second advice: Make the forms/dialogs ignore all clicks for the first 500ms 
after showing/creation. Maybe by "setEnabled( false )" followed by a delayed
"setEnabled( true )". I think these also propagate to all subwidgets, so it 
should be save to do this on the main-widget only.

Dealing with the mouse-clicks yourself will get very complicated.

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090717/51207d22/attachment.bin 


More information about the Qt-interest-old mailing list