Programming Language: C++ (Cpp)

Class/Type: QRect

Method/Function: adjusted

Examples at hotexamples.com: 30

QRect adjusted is a member function of the class QRect in the Qt library. It allows you to adjust the size of the rectangle by adding or subtracting a value from each of its coordinates. This can be useful if you need to make a rectangle slightly larger or smaller.

Here are some code examples using QRect adjusted:

**Example 1:**

This code creates a rectangle with top-left corner at (10, 10) and a width and height of 50. The `adjust` function is then called with arguments of 5, 5, -5, -5 - this means to add 5 to the x-coordinate of the top-left corner, add 5 to the y-coordinate of the top-left corner, subtract 5 from the x-coordinate of the bottom-right corner, and subtract 5 from the y-coordinate of the bottom-right corner. After this call, `myRect` will have the same center point, but will be slightly smaller.

**Example 2:**

Here are some code examples using QRect adjusted:

QRect myRect(10, 10, 50, 50); myRect.adjust(5, 5, -5, -5);

This code creates a rectangle with top-left corner at (10, 10) and a width and height of 50. The `adjust` function is then called with arguments of 5, 5, -5, -5 - this means to add 5 to the x-coordinate of the top-left corner, add 5 to the y-coordinate of the top-left corner, subtract 5 from the x-coordinate of the bottom-right corner, and subtract 5 from the y-coordinate of the bottom-right corner. After this call, `myRect` will have the same center point, but will be slightly smaller.

QRect myRect(0, 0, 100, 100); myRect.adjust(-10, -10, 10, 10);This code creates a rectangle with top-left corner at (0, 0) and a width and height of 100. The `adjust` function is then called with arguments of -10, -10, 10, 10 - this means to subtract 10 from the x-coordinate of the top-left corner, subtract 10 from the y-coordinate of the top-left corner, add 10 to the x-coordinate of the bottom-right corner, and add 10 to the y-coordinate of the bottom-right corner. After this call, `myRect` will have the same center point, but will be slightly larger. The Qt library contains the QRect class and its related functions.

Frequently Used Methods

Frequently Used Methods

Related

Related in langs