QRect setLeft is a function in the Qt library for C++ that sets the left edge of a rectangle to a specified position. The function takes an integer value as its argument and returns a new QRect object with the updated position.
Example 1:
```c++ #include
int main() { QRect rect(10, 20, 30, 40); // create a rectangle with left edge at 10 rect.setLeft(5); // set the left edge to 5 // rect now has a left edge at position 5 return 0; }
In this example, we create a QRect object with a left edge at position 10 and then use setLeft to update its position to 5.
Example 2:
c++
#include
#include
int main()
{
QRect rect1(10, 20, 30, 40);
QRect rect2 = rect1;
rect2.setLeft(5);
qDebug() << "rect1: " << rect1 << ", rect2: " << rect2;
// output: "rect1: QRect(10,20 30x40) , rect2: QRect(5,20 35x40)"
return 0;
}
```
In this example, we create two QRect objects, rect1 and rect2, with rect1 having a left edge at 10 and rect2 being a copy of rect1. We then use setLeft on rect2 to update its position, and print out both rectangles to show the difference in their positions.
The package library for QRect setLeft is the Qt library for C++.
C++ (Cpp) QRect::setLeft - 30 examples found. These are the top rated real world C++ (Cpp) examples of QRect::setLeft extracted from open source projects. You can rate examples to help us improve the quality of examples.