#includeint main() { QRect rect(0, 0, 100, 100); // create a rectangle with top-left corner at (0, 0) and size 100x100 QRect newRect = rect.moveLeft(rect.left() - 10); // move the left edge to the left by 10 pixels // newRect now has a top-left corner of (-10, 0) and size 100x100 return 0; }
#includePackage/Library: Qt5Core.#include #include int main() { QWidget widget; QRect rect(0, 0, 100, 100); // create a rectangle with top-left corner at (0, 0) and size 100x100 widget.setGeometry(rect); // set the geometry of the widget to the rectangle QPropertyAnimation anim(&widget, "geometry"); // create an animation to change the widget's geometry anim.setDuration(1000); // animate for 1 second anim.setStartValue(rect); // start from the original rectangle QRect endRect = rect.moveLeft(rect.left() - 100); // move the left edge to the left by 100 pixels anim.setEndValue(endRect); // end at the new rectangle anim.start(); // start the animation widget.show(); // show the widget return 0; }