QgsRectangle rect1 = QgsRectangle(0, 0, 10, 10); QgsRectangle rect2 = QgsRectangle(5, 5, 15, 15); rect1.combineExtentWith(rect2);
QgsRectangle rect1 = QgsRectangle(0, 0, 10, 10); QgsRectangle rect2 = QgsRectangle(15, 15, 20, 20); rect1.combineExtentWith(rect2);In this example, the initial rectangle is defined by the coordinates (0,0) and (10,10). The second rectangle to combine is defined by the coordinates (15,15) and (20,20). The combineExtentWith function is used to create a new rectangle that covers both of these rectangles, which will have the same coordinates as rect2, namely (15,15) and (20,20). Overall, QgsRectangle is a helpful class for working with spatial data in C++, and the combineExtentWith function is a useful method for dealing with multiple rectangles. The QgsRectangle class is part of the QGIS library, which is an open source library for GIS development.