QRect rect1(0, 0, 20, 30); if (rect1.isValid()) { // do something } else { // rect1 is invalid }
QRect rect2(-10,-10,0,0); if (rect2.isValid()) { // do something } else { //rect2 is invalid }In this example, another QRect object is created with negative values for the coordinates. This time, the rectangle has zero width and height. The isValid() method is called again, and it returns false since this rectangle is invalid. QRect and its methods are part of the Qt library package.