Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt animation for groupbox
Qt 6.11 is out! See what's new in the release blog

Qt animation for groupbox

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    frsdot
    wrote on last edited by
    #1

    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);

    }@

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Is your groupBox in a layout in a widget ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved