51 views
in GUI Development by

Hi, 

I am encountering a problem with a pushbutton I am using to add or subtract value to my given data. The problem I am facing is that my pushbutton works fine when I am pressing it once and it adds to the value but then I want to hold it for two seconds and make it trigger to add 10 values to the existing value every two second for as long as it's held. What can I do to solve this? I am having a hard time understanding properties. 

1 Answer

+1 vote
by

Hello,

use Timer for this purpose. When the user presses the button the timer should start. When the user releases the button, the timer should stop. To achieve this assign the timers slot method StartTimer to the button's property OnPress. Then assign the timer's slot method StopTimer to the buttons OnRelease property. Both steps are demonstrated below (see also Start, stop and restart the Timer object and Implement Push Button's slot methods):

 

Then add a new slot method and assign it to the timer's OnTrigger property. In the slot method you can implement the code you want to be executed with the delay or periodically.

Finally configure the timing of the timer. With the property Begin you specify the initial timer delay. With the property Period you can specify the timer interval. See also Specify the timer interval and the initial delay.

I hope it helps you further.

Best regards

Paul Banach

Embedded Wizard Website | Privacy Policy | Imprint

...