PDA

View Full Version : QPropertyAnimation how to lock button slot to avoid reset of animation



Andre4e
20th February 2012, 20:38
i have this code:



void myclass::on_btn_slot()
{
QPropertyAnimation *a = new QPropertyAnimation( ui->btn , "geometry" );
a->setStart.....
a->setEnd....
a->setDuration...
a->setLoopCount....
a->start(QAbstractAnimation::Delete....);
}


Once that animation is playing, how can I disable the call of the slot?
Because then if I click during animation, this resets.

I do not want to disable the button and I seek a solution that allows me
handle everything in this method / slot


i thinked to use a boolean but i should to connect the finish signal of animation with a method

Jonny174
21st February 2012, 01:49
QPushButton *btn = ....;
connect( btn, SIGNAL(clicked), this, SLOT(on_btn_slot()) );


To disable use disconnect( btn, 0, 0, 0 ), and connect( btn, SIGNAL(clicked), this, SLOT(on_btn_slot()) ); to connect again. No?

MarekR22
21st February 2012, 11:13
@up: crappy solution.

The bast way is to use state machine. Then switching state will start animation. See QStateMachine documentation (http://developer.qt.nokia.com/doc/qt-4.8/statemachine-api.html).

Another solution is disable button and then enable it again when animation is ended.