QPainter painter(this); painter.setClipping(true); painter.setClipRect(50, 50, 100, 100); painter.drawRect(0, 0, 200, 200);
QPainter painter(this); painter.setClipping(true); painter.setClipPath(shape); painter.drawRect(0, 0, 200, 200);This code sets the clipping region to a circular shape and draws a rectangle that fills the entire canvas. Same as above, only the portion of the rectangle that intersects with the circular clipping region will be visible. Package Library: This functionality is provided by the Qt graphical user interface development framework mainly used for creating desktop and mobile applications.