Qt animation for groupbox
-
I have a groupbox to which I want to add animation. I created my custom group box class and implemented the mouster enter and leave event. On mouse enter , I check the height and decrease or increase it with animation but does not seem to work .
int height = groupBox->height();
@
if ( height >= 40 ) // if height is already increased set , decrease it. {int groupBoxHeight = 15;
QPropertyAnimation *animation = new QPropertyAnimation(groupBox, "geometry");
animation->setDuration(2000);
animation->setStartValue(QRect(this->x(), this->y(), this->width(), this->height()));
animation->setEndValue(QRect(this->x(), this->y(), this->width(), groupBoxHeight));
animation->setEasingCurve(QEasingCurve::OutBounce);
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
else
{
int groupboxHeight = 50;
groupBox->setGeometry(groupBox->geometry().x(), groupBox->geometry().y(), groupBox->width(), groupboxHeight);QPropertyAnimation *animation = new QPropertyAnimation(groupBox, "geometry");
animation->setDuration(2000);
animation->setStartValue(QRect(this->x(), this->y(), this->width(), this->height()));
animation->setEndValue(QRect(this->x(), this->y(), this->width(), groupboxHeight));
animation->setEasingCurve(QEasingCurve::OutBounce);
animation->start(QAbstractAnimation::DeleteWhenStopped);}@
-
Hi,
Is your groupBox in a layout in a widget ?