RuLoViC
RuLoViC

Reputation: 855

Do something while QPushbutton is pressed

I have a Qt application. There I want to trigger some action while QPushButton is pressed and stop it when button is released. I have read a bit and so far what I found is to reimplement mousePressEvent to start timer to emit signals and do my action and also reimplement mouseReleaseEvent to stop that timer. Is there any other way or that one is the most correct one?

Thanks and regards

Upvotes: 1

Views: 2276

Answers (2)

shahina
shahina

Reputation: 128

You can use the signal of pressed() and released() of QPushButton

Upvotes: 1

The Quantum Physicist
The Quantum Physicist

Reputation: 26346

There are signals for pressed() and released() for QPushButton. Connect pressed() to activate whatever you want to be activated while the button is pressed, and stop it when released() is signaled.

Upvotes: 3

Related Questions