QRect rect(0, 0, 100, 100); // creates a rectangle at (0, 0) with width 100 and height 100 rect.setRight(150); // sets the right edge of the rectangle to x-coordinate 150
QRect rect(50, 50, 100, 100); // creates a rectangle at (50, 50) with width 100 and height 100 int newRight = rect.right() + 50; // calculates the new x-coordinate for the right edge rect.setRight(newRight); // sets the right edge of the rectangle to the new x-coordinateThis code creates a rectangle at (50, 50) with width 100 and height 100. Then, a new x-coordinate for the right edge is calculated by adding 50 to the current x-coordinate of the right edge. Finally, the setRight function is called to set the right edge of the rectangle to the new x-coordinate. As a result, the rectangle becomes wider and its right edge moves to the right. Package library: Qt.