I'm new to QT and am making a widget that interfaces with a pre-existing gui. I'd like to have my widget continuously output one signal while the user has a pushbutton pressed and then continuously output another when it is released.
By enabling autorepeat I can have the widget output my signal while the user is pressing the pushbutton, however, the output signal switches between pressed() and released(). E.G.
<> Outputs: * pressed signal * released signal * pressed signal * released signal
I've seen this question been asked about keyPressEvents but I'm not sure how to access isAutoRepeat() for PushButtons. Can someone give me advice on this?
One way is you can use timer object to achieve this. Below is the example, that will run the 2 slot's when button pressed and released. The code comment will explain in detail. when button pressed & released a text box will show the continuous time in Milli-seconds. Timer is an object that will emit the timeout() signal in a given interval. We need to stop and start the alternate timers in button pressed / released signal. This application created using the QT Creator "QT Widgets Application" wizard. Hope this help.
//Header File
//CPP file