QRectF rect(0, 0, 50, 50); // create a rectangle at (0, 0) with width and height of 50 rect.moveTopLeft(QPointF(10, 20)); // move the top-left point to (10, 20)
QRectF rect(0, 0, 50, 50); // create a rectangle at (0, 0) with width and height of 50 QPointF offset(5, 10); // define an offset of (5, 10) to move the rectangle by rect.moveTopLeft(rect.topLeft() + offset); // move the top-left point by the offsetIn this example, we create a rectangle with top-left point at (0, 0) and width and height of 50. We define an offset of (5, 10) to move the rectangle by, and then use `moveTopLeft()` to move the top-left point by the offset. Package library: Qt.