Skip to content

PythonQt.Qt.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 (shared captured text)
Rectangle attribute Any (shared captured text)
RegionType attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
__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 (shared captured text)
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 (shared captured text)
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 (shared captured text)
intersects function (self, r: Any) -> bool X.intersects(r) -> bool (shared captured text)
isEmpty function (self) -> bool X.isEmpty() -> bool (shared captured text)
isNull function (self) -> bool X.isNull() -> bool (shared captured text)
readFrom function (self, arg__1: Any) -> Any (shared captured text)
rectCount function (self) -> int X.rectCount() -> int (shared captured text)
rects function (self) -> tuple X.rects() -> tuple (shared captured text)
setRects function (self, rect: Any, num: int) -> None X.setRects(rect, num) (shared captured text)
subtracted function (self, r: Any) -> Any X.subtracted(r) -> PythonQt.QtGui.QRegion (shared captured text)
swap function (self, other: Any) -> None Swaps region other with this region. (shared captured text)
translate function (self, dx: Any, dy: Any) -> None X.translate(dx, dy) (shared captured text)
translated function (self, dx: Any, dy: Any) -> Any X.translated(dx, dy) -> PythonQt.QtGui.QRegion (shared captured text)
united function (self, r: Any) -> Any X.united(r) -> PythonQt.QtGui.QRegion (shared captured text)
writeTo function (self, arg__1: Any) -> Any (shared captured text)
xored function (self, r: Any) -> Any X.xored(r) -> PythonQt.QtGui.QRegion (shared captured text)