You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, October 11th 2007, 5:28pm

Custom spinner - fast increment/decrement

Hi,

I am implementing a custom spinner control built using 2 small
buttons and a QLineEdit. Everything is in place and working. One
button increments the linedit, the other decrements it.

I would like to add functionality where if you click and hold
one of the buttons then after 2 secs or so the increment/decrement
speed is much faster.

I have some ideas using a timer and so forth, but perhaps there
is some already available functionality I am not aware of.

Any suggestions?

Many thanks!

Mark

mchara

Trainee

  • "mchara" is male

Posts: 99

Location: Poland

Occupation: developer

  • Send private message

2

Friday, October 12th 2007, 6:55am

I think timer is good idea here, but I advise you to start the timer on mousePress and stop it after those 2 sec. to not let the timer working unused(lots of them can slowdown your application).
I would change some bool when timer stops after 2 seconds from mouse press and reset it on mouseRelease.
But if you'll need second timer to control increments/decrements timing when button is pressed, there's no sense of having two timers per widget, so maybe changing increment speed after some number of ticks instead of waiting those 2 seconds on sec timer.
You may also check QTime class - it allows you to get time on mousePress and measure time that passed without second timer.
mc