Solved Is it possible to change value of widget when animation loop is incremented?
-
Hello!
I wonder if there is possibility to change position of widget after loop. For example, we have widget that is being animated and if animation ends we change its position and animate it again (something like reset, but in other place/position).I was thinking about creating individual class derived from QAbstractAnimation just to override LoopCount or function responsible for looping, but i am lost right know and i don't know if there isn't maybe easier and faster way to go. It should look
like this:Endless Loop {
- animate
- if animation ends, change position of widget
- animate it again
}
Do you know any hints? I will be grateful :)
Cheers! -
-
Thanks for reply, however i still can't do it. I am struggling with connecting animation with any widget.
animation = new QPropertyAnimation(ui->label_2, "geometry"); //code handling animation... QObject::connect(animation, SIGNAL(currentLoopChanged()), ui->pushButton, SLOT(changeText()));
This is doing nothing. Like signal is not being send.
ChangeText function:
void MainWindow::changeText(int) { int randomValue = random<int>(this->height() - this->height(), this->height()); ui->pushButton->setText(QString::number(randomValue)); }
Do you see something suspicious in this connect?
Awww this problem is devouring so much time haha! For sure it is, because my Qt5 knowledge is so tiny :)
Cheers! -
Alright nevermind, finally i understood how connections work and i implemented one properly this time. Thanks for help.