QRect rect1(10, 10, 50, 50); QRect rect2(30, 30, 50, 50); QRect intersection = rect1.intersect(rect2); // intersection now represents the rectangle (30, 30, 30, 30)
QRect rect1(10, 10, 50, 50); QRect rect2(60, 60, 50, 50); QRect intersection = rect1.intersect(rect2); // intersection is now an invalid QRect objectIn this example, `rect1` and `rect2` are two rectangles that do not overlap. Therefore, calling `intersect` results in an invalid `QRect` object. Overall, `QRect` belongs to the Qt Core module library, and is useful for representing rectangular shapes and calculating their intersections.