I have a code:
void testbutton::buttonPressEvent(bool pressed_arg){
QPropertyAnimation *animation = new QPropertyAnimation(m_button_bg, "size", this);
animation->setDuration(500);
animation->setEasingCurve(QEasingCurve::InCurve);
int maxwidth = mwidth;
if(pressed_arg == true)
{
animation->setStartValue(QSize(m_button_bg->width(), 39));
animation->setEndValue(QSize(39, 39));
pressed = false;
animation->start();
}
else{
animation->setStartValue(QSize(m_button_bg->width(), 39));
animation->setEndValue(QSize(maxwidth, 39));
pressed = true;
text_button->show();
animation->start();
}
}
I want the text_button to be hidden after the end of the animation from the pressed_arg == true option, because the animation itself cannot do this due to the fact that this button contains text and cannot be compressed to zero, so I want to track the end of the animation and then apply text_button->hide().
How can I do that?
P.S: the animation compresses the frame in which this button is located.
I tried:
animation->start();
text_button->hide();
but the button disappeared right when the animation started, and it doesn't look like I expected it.
QPropertyAnimation inherits QAbstractAnimation which provides a finished signal, connect it to a your
text_button'shidemethod.see this for more information.