Push button long&short time press control
-
Hi
You want to know how long a user hold down the button?
There is
http://doc.qt.io/qt-5.5/qelapsedtimer.html#details -
@mrjj
Yes, i want to know if button pressed short and released or it is pressed long time (maybe 1000ms). first i think maybe a timer can be defined globally and button pressed and released functions can be used to control the short or long press, but i can not use a global timer , you maybe give idea more clearly. -
Ok, it doesn't have to be global, but could live
in the class that has ::on_pushButton_XXAlternatively you could subclass QPushButton and create one
that can do this it self ? (internal handling of the QElapsedTimer)Can I ask why you need to know this?
Most will just click it and released will come very fast. -
@rapid84
ok. I understand.
There is also
http://doc.qt.io/qt-5.5/qabstractbutton.html#autoRepeat-prop
You could just "count" and use the count to decide if function 1 or 2.If you need this for more that 1 button, a new Button type is the way to go.
You could even make new signal giving the pressed time or count.