PDA

View Full Version : Sending signals from QPushButton



Cucus
18th July 2011, 23:40
Hi,

Is it possible to send a lot of signals from a QPushButton if we still pressing the button all the time?

Thanks

squidge
18th July 2011, 23:48
Woudn't it be easier to fire a QTimer on the press and release of the button and let the timer fire the events are your expected intervals?

Cucus
18th July 2011, 23:50
How can I do this?

Santosh Reddy
19th July 2011, 05:06
check this out

QPushButton * button = QPushButton("Press Me Long", this);
QTimer * timer = new QTimer(this); //0 ms timer, the fastest possible QTimer
connect(timer, SIGNAL(timeout()), this, SIGNAL(MySignal()); //Note: signal connected to signal
connect(button, SIGNAL(pressed()), timer, SLOT(start()));
connect(button, SIGNAL(released()), timer, SLOT(stop()));