PDA

View Full Version : Press one button - emit signal more time



SirJonas
24th October 2016, 17:47
it's possible to use some bolean to avoid press one button all time? For example sometimes i'm doing thing's repetitive for example i'm doing some paint with qt and i want when i press button all time draw. In other words, it is possible to put on one botton pressed all time with some boolean to avoid press many times.

anda_skoa
24th October 2016, 18:19
Do you want to ignore button presses?
Or disable the button?

Cheers,
_

SirJonas
24th October 2016, 18:34
something like when i press the button, the button all time is sending so the slot is openned all time something like said. For example i press one button and draw me circles. But i want when i pressed the button one time the signal is emiting all time so will draw all time circles. I searched in internet and said me call the slot but i think i need to call slot all time. It's like one button is pressed is desactivated, Anyway i'm not sure if i call all time the slot maybe i can repeat these things all time.

adutzu89
25th October 2016, 08:32
Make a boolean variable, example: drawCircleChecked, and put a if condition if(drawCircleChecked == true) { paint(); }.
There is no need for signal / slot mechanism here if I understand correctly.
Also buttons in Qt can be made checkable, meaning click for check / click for uncheck, so when drawing you can check which button has been checked.

anda_skoa
25th October 2016, 10:03
something like when i press the button, the button all time is sending so the slot is openned all time something like said.

If you want to continuously call a slot, you need a QTimer.
Your button the simply starts or stops that timer.

Cheers,
_