[Interest] QSpinBox threshold timer

André Somers andre at familiesomers.nl
Mon Jul 22 16:18:01 CEST 2013


Op 22-7-2013 14:46, Carl Schumann schreef:
> Hi,
>
> I am writing an application which allows the user to display content
> from a database.  The user controls what DB content is displayed via a
> QSpinBox.   So I connect the value changed signal of the spin box to a
> slot which queries the DB and updates the model with the results.
>
> Unfortunately, when the user clicks once on the up or down buttons the
> value changed signal is sent twice.   I have compiled Qt with debug and
> made the following observation.   The first signal appears to be
> directly a result of the click.   The second signal appears to be the
> sent when the "spinClickThresholdTimer" expires. Apparently. this timer
> is part of logic to determine if the mouse button is being held down so
> the user can rapidly advance the spin box value.   In my scenario though
> the mouse button is not being held down.
>
> The timeout on the above timer is apparently 500 milliseconds. This is
> in the ballpark of the time taken by the DB query.   If I modify the
> above slot to not do the DB query I don't see the duplicated signal, of
> course, the spin box value and DB values are then out of sync.
>
> Any ideas about what I can do to correct the above scenario would be
> appreciated please.   Thanks for your time.
>
> Sincerely,
> Carl Schumann
>
>
>
To me, it sounds like you need an asynchronous model implemenation, that 
doesn't do the database query in the main thread.
If updating a single value takes half a second, and your UI becomes 
unresponsive for that time every type you click up or down, then you 
have a problem I'd say.

André

-- 
You like Qt?
I am looking for collegues to join me at i-Optics!




More information about the Interest mailing list