QPropertyAnimation *anim = new QPropertyAnimation(widget, "pos"); anim->setDuration(1000); // duration in milliseconds anim->setStartValue(QPoint(0, 0)); // start position anim->setEndValue(QPoint(100, 100)); // end position anim->start();
QPropertyAnimation *anim = new QPropertyAnimation(label, "geometry"); anim->setDuration(500); // duration in milliseconds anim->setStartValue(QRect(0, 0, 100, 100)); // start size anim->setEndValue(QRect(0, 0, 200, 200)); // end size anim->start();In this example, a QPropertyAnimation object is created to animate the geometry property of a QLabel (which includes the size of the label). The setStartValue() function is used to set the starting size of the label to a QRect with width and height of 100. Package Library: Qt GUI Library.