Skip to content

PythonQt.QtGui.QRegion

QRegion

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

QRegion is used with QPainter::setClipRegion() to limit the paint area to what needs to be painted. There is also a QWidget::repaint() function that takes a QRegion parameter. QRegion is the best tool for minimizing the amount of screen area to be updated by a repaint.

This class is not suitable for constructing shapes for rendering, especially as outlines. Use QPainterPath to create paths and shapes for use with QPainter.

QRegion is an implicitly shared class.

Creating and Using Regions

A region can be created from a rectangle, an ellipse, a polygon or a bitmap. Complex regions may be created by combining simple regions using united(), intersected(), subtracted(), or xored() (exclusive or). You can move a region using translate().

You can test whether a region isEmpty() or if it contains() a QPoint or QRect. The bounding rectangle can be found with boundingRect().

Iteration over the region (with begin(), end(), or ranged-for loops) gives a decomposition of the region into rectangles.

Example of using complex regions:

void MyWidget::paintEvent(QPaintEvent *)
{
    QRegion r1(QRect(100, 100, 200, 80),    // r1: elliptic region
               QRegion::Ellipse);
    QRegion r2(QRect(100, 120, 90, 30));    // r2: rectangular region
    QRegion r3 = r1.intersected(r2);        // r3: intersection

    QPainter painter(this);
    painter.setClipRegion(r3);
    ...                                     // paint clipped graphics
}

Source: https://doc.qt.io/archives/qt-5.15/qregion.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
Ellipse attribute Any
Rectangle attribute Any
RegionType attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
boundingRect function (self) -> Any X.boundingRect() -> PythonQt.QtCore.QRect
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
contains function (self, p: Any) -> bool X.contains(p) -> bool
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
intersected function (self, r: Any) -> Any X.intersected(r) -> PythonQt.QtGui.QRegion
intersects function (self, r: Any) -> bool X.intersects(r) -> bool
isEmpty function (self) -> bool X.isEmpty() -> bool
isNull function (self) -> bool X.isNull() -> bool
readFrom function (self, arg__1: Any) -> Any (shared captured text)
rectCount function (self) -> int X.rectCount() -> int
rects function (self) -> tuple X.rects() -> tuple
setRects function (self, rect: Any, num: int) -> None X.setRects(rect, num)
subtracted function (self, r: Any) -> Any X.subtracted(r) -> PythonQt.QtGui.QRegion
swap function (self, other: Any) -> None Swaps region other with this region.
translate function (self, dx: Any, dy: Any) -> None X.translate(dx, dy)
translated function (self, dx: Any, dy: Any) -> Any X.translated(dx, dy) -> PythonQt.QtGui.QRegion
united function (self, r: Any) -> Any X.united(r) -> PythonQt.QtGui.QRegion
writeTo function (self, arg__1: Any) -> Any (shared captured text)
xored function (self, r: Any) -> Any X.xored(r) -> PythonQt.QtGui.QRegion