![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QRegion class specifies a clip region for a painter. More...
#include <qregion.h>
Public Types | |
| enum | RegionType { Rectangle , Ellipse } |
| Specifies the shape of the region to be created. More... | |
| typedef const QRect * | const_iterator |
| typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
Public Member Functions | |
| QRegion () | |
| Constructs an empty region. | |
| QRegion (int x, int y, int w, int h, RegionType t=Rectangle) | |
| Constructs a rectangular or elliptic region. | |
| QRegion (const QRect &r, RegionType t=Rectangle) | |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Create a region based on the rectangle r with region type t. | |
| QRegion (const QPolygon &pa, Qt::FillRule fillRule=Qt::OddEvenFill) | |
| Constructs a polygon region from the point array a with the fill rule specified by fillRule. | |
| QRegion (const QRegion ®ion) | |
| Constructs a new region which is equal to region r. | |
| QRegion (QRegion &&other) noexcept | |
| QRegion (const QBitmap &bitmap) | |
| Constructs a region from the bitmap bm. | |
| ~QRegion () | |
| QRegion & | operator= (const QRegion &) |
| Assigns r to this region and returns a reference to the region. | |
| void | swap (QRegion &other) noexcept |
| bool | isEmpty () const |
Returns true if the region is empty; otherwise returns false. | |
| bool | isNull () const |
| const_iterator | begin () const noexcept |
| const_iterator | cbegin () const noexcept |
| const_iterator | end () const noexcept |
| const_iterator | cend () const noexcept |
| const_reverse_iterator | rbegin () const noexcept |
| const_reverse_iterator | crbegin () const noexcept |
| const_reverse_iterator | rend () const noexcept |
| const_reverse_iterator | crend () const noexcept |
| bool | contains (const QPoint &p) const |
Returns true if the region contains the point p; otherwise returns false. | |
| bool | contains (const QRect &r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the region overlaps the rectangle r; otherwise returns false. | |
| void | translate (int dx, int dy) |
| Translates (moves) the region dx along the X axis and dy along the Y axis. | |
| void | translate (const QPoint &p) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Translates the region {point}{.x()} along the x axis and {point}{.y()} along the y axis, relative to the current position. | |
| QRegion | translated (int dx, int dy) const |
| QRegion | translated (const QPoint &p) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| QRegion | united (const QRegion &r) const |
| QRegion | united (const QRect &r) const |
| QRegion | intersected (const QRegion &r) const |
| QRegion | intersected (const QRect &r) const |
| QRegion | subtracted (const QRegion &r) const |
| QRegion | xored (const QRegion &r) const |
| bool | intersects (const QRegion &r) const |
| bool | intersects (const QRect &r) const |
| QRect | boundingRect () const noexcept |
| Returns the bounding rectangle of this region. | |
| void | setRects (const QRect *rect, int num) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. \obsolete Use the QSpan overload instead. | |
| void | setRects (QSpan< const QRect > r) |
| QSpan< const QRect > | rects () const noexcept |
| int | rectCount () const noexcept |
| QRegion | operator| (const QRegion &r) const |
| Applies the united() function to this region and r. | |
| QRegion | operator+ (const QRegion &r) const |
| Applies the united() function to this region and r. | |
| QRegion | operator+ (const QRect &r) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| QRegion | operator& (const QRegion &r) const |
| Applies the intersected() function to this region and r. | |
| QRegion | operator& (const QRect &r) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| QRegion | operator- (const QRegion &r) const |
| Applies the subtracted() function to this region and r. | |
| QRegion | operator^ (const QRegion &r) const |
| Applies the xored() function to this region and r. | |
| QRegion & | operator|= (const QRegion &r) |
| Applies the united() function to this region and r and assigns the result to this region. | |
| QRegion & | operator+= (const QRegion &r) |
| Applies the united() function to this region and r and assigns the result to this region. | |
| QRegion & | operator+= (const QRect &r) |
| Returns a region that is the union of this region with the specified rect. | |
| QRegion & | operator&= (const QRegion &r) |
| Applies the intersected() function to this region and r and assigns the result to this region. | |
| QRegion & | operator&= (const QRect &r) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| QRegion & | operator-= (const QRegion &r) |
| Applies the subtracted() function to this region and r and assigns the result to this region. | |
| QRegion & | operator^= (const QRegion &r) |
| Applies the xored() function to this region and r and assigns the result to this region. | |
| bool | operator== (const QRegion &r) const |
Returns true if the region is equal to r; otherwise returns false. | |
| bool | operator!= (const QRegion &r) const |
Returns true if this region is different from the other region; otherwise returns false. | |
| operator QVariant () const | |
| Returns the region as a QVariant. | |
Friends | |
| struct | QRegionPrivate |
| Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &, const QRegion &) |
| Writes the region r to the stream s and returns a reference to the stream. | |
| Q_GUI_EXPORT QDataStream & | operator>> (QDataStream &, QRegion &) |
| Reads a region from the stream s into r and returns a reference to the stream. | |
| Q_GUI_EXPORT friend bool | qt_region_strictContains (const QRegion ®ion, const QRect &rect) |
The QRegion class specifies a clip region for a painter.
\inmodule QtGui
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 \l{implicitly shared} class.
| typedef const QRect* QRegion::const_iterator |
| typedef std::reverse_iterator<const_iterator> QRegion::const_reverse_iterator |
| enum QRegion::RegionType |
| QRegion::QRegion | ( | ) |
| QRegion::QRegion | ( | int | x, |
| int | y, | ||
| int | w, | ||
| int | h, | ||
| RegionType | t = Rectangle ) |
Constructs a rectangular or elliptic region.
If t is Rectangle, the region is the filled rectangle (x, y, w, h). If t is Ellipse, the region is the filled ellipse with center at (x + w / 2, y + h / 2) and size (w ,h).
Definition at line 160 of file qregion.cpp.
| QRegion::QRegion | ( | const QRect & | r, |
| RegionType | t = Rectangle ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Create a region based on the rectangle r with region type t.
If the rectangle is invalid a null region will be created.
Definition at line 3798 of file qregion.cpp.
| QRegion::QRegion | ( | const QPolygon & | a, |
| Qt::FillRule | fillRule = Qt::OddEvenFill ) |
Constructs a polygon region from the point array a with the fill rule specified by fillRule.
If fillRule is \l{Qt::WindingFill}, the polygon region is defined using the winding algorithm; if it is \l{Qt::OddEvenFill}, the odd-even fill algorithm is used.
Definition at line 3815 of file qregion.cpp.
| QRegion::QRegion | ( | const QRegion & | region | ) |
Constructs a new region which is equal to region r.
Definition at line 3831 of file qregion.cpp.
|
inlinenoexcept |
| QRegion::QRegion | ( | const QBitmap & | bm | ) |
Constructs a region from the bitmap bm.
The resulting region consists of the pixels in bitmap bm that are Qt::color1, as if each pixel was a 1 by 1 rectangle.
This constructor may create complex regions that will slow down painting when used. Note that drawing masked pixmaps can be done much faster using QPixmap::setMask().
Definition at line 3838 of file qregion.cpp.
| QRegion::~QRegion | ( | ) |
Destroys the region.
Definition at line 3854 of file qregion.cpp.
|
noexcept |
Returns a const_iterator pointing to the beginning of the range of non-overlapping rectangles that make up the region.
The union of all the rectangles is equal to the original region.
Definition at line 4202 of file qregion.cpp.
|
noexcept |
Returns the bounding rectangle of this region.
An empty region gives a rectangle that is QRect::isNull().
Definition at line 4158 of file qregion.cpp.
|
inlinenoexcept |
|
inlinenoexcept |
| bool QRegion::contains | ( | const QPoint & | p | ) | const |
Returns true if the region contains the point p; otherwise returns false.
Definition at line 3899 of file qregion.cpp.
| bool QRegion::contains | ( | const QRect & | r | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the region overlaps the rectangle r; otherwise returns false.
Definition at line 3904 of file qregion.cpp.
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
Returns a const_iterator pointing to one past the end of non-overlapping rectangles that make up the region.
The union of all the rectangles is equal to the original region.
Definition at line 4207 of file qregion.cpp.
Returns a region which is the intersection of this region and the given rect.
Definition at line 4089 of file qregion.cpp.
Returns a region which is the intersection of this region and r.
Region Intersection
The figure shows the intersection of two elliptical regions.
Definition at line 4044 of file qregion.cpp.
| bool QRegion::intersects | ( | const QRect & | rect | ) | const |
Returns true if this region intersects with rect, otherwise returns false.
Definition at line 4302 of file qregion.cpp.
| bool QRegion::intersects | ( | const QRegion & | region | ) | const |
Returns true if this region intersects with region, otherwise returns false.
Definition at line 605 of file qregion.cpp.
| bool QRegion::isEmpty | ( | ) | const |
Returns true if the region is empty; otherwise returns false.
An empty region is a region that contains no points.
Example:
Definition at line 3889 of file qregion.cpp.
| bool QRegion::isNull | ( | ) | const |
Returns true if the region is empty; otherwise returns false. An empty region is a region that contains no points. This function is the same as isEmpty
Definition at line 3894 of file qregion.cpp.
| QRegion::operator QVariant | ( | ) | const |
Returns the region as a QVariant.
Definition at line 541 of file qregion.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 431 of file qregion.cpp.
Applies the intersected() function to this region and r.
r1&r2 is equivalent to r1.intersected(r2).
Definition at line 424 of file qregion.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 503 of file qregion.cpp.
Applies the intersected() function to this region and r and assigns the result to this region.
r1&=r2 is equivalent to r1 = r1.intersected(r2).
Definition at line 490 of file qregion.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 415 of file qregion.cpp.
Applies the united() function to this region and r.
r1+r2 is equivalent to r1.united(r2).
Definition at line 408 of file qregion.cpp.
Returns a region that is the union of this region with the specified rect.
Definition at line 4015 of file qregion.cpp.
Applies the united() function to this region and r and assigns the result to this region.
r1+=r2 is equivalent to {r1 = r1.united(r2)}.
Definition at line 3953 of file qregion.cpp.
Applies the subtracted() function to this region and r.
r1-r2 is equivalent to r1.subtracted(r2).
Definition at line 442 of file qregion.cpp.
Applies the subtracted() function to this region and r and assigns the result to this region.
r1-=r2 is equivalent to {r1 = r1.subtracted(r2)}.
Definition at line 518 of file qregion.cpp.
Assigns r to this region and returns a reference to the region.
Move-assigns other to this QRegion instance.
Definition at line 3861 of file qregion.cpp.
| bool QRegion::operator== | ( | const QRegion & | r | ) | const |
Returns true if the region is equal to r; otherwise returns false.
Definition at line 4289 of file qregion.cpp.
Applies the xored() function to this region and r.
r1^r2 is equivalent to r1.xored(r2).
Definition at line 451 of file qregion.cpp.
Applies the xored() function to this region and r and assigns the result to this region.
r1^=r2 is equivalent to {r1 = r1.xored(r2)}.
Definition at line 528 of file qregion.cpp.
Applies the united() function to this region and r.
r1|r2 is equivalent to r1.united(r2).
Definition at line 399 of file qregion.cpp.
Applies the united() function to this region and r and assigns the result to this region.
r1|=r2 is equivalent to {r1 = r1.united(r2)}.
Definition at line 461 of file qregion.cpp.
|
inlinenoexcept |
|
noexcept |
Returns the number of rectangles that this region is composed of. Same as {end() - begin()}.
Definition at line 4284 of file qregion.cpp.
Returns a span of non-overlapping rectangles that make up the region. The span remains valid until the next call of a mutating (non-const) method on this region.
The union of all the rectangles is equal to the original region.
Definition at line 4279 of file qregion.cpp.
|
inlinenoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. \obsolete Use the QSpan overload instead.
Definition at line 4218 of file qregion.cpp.
Sets the region using the array of rectangles specified by rects. The rectangles must be optimally Y-X sorted and follow these restrictions:
\list
{rects.size()} must be less than {INT_MAX} (see rectCount()).Definition at line 4227 of file qregion.cpp.
Returns a region which is r subtracted from this region.
Region Subtraction
The figure shows the result when the ellipse on the right is subtracted from the ellipse on the left ({left - right}).
Definition at line 4115 of file qregion.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Translates the region {point}{.x()} along the x axis and {point}{.y()} along the y axis, relative to the current position.
Positive values move the region to the right and down.
Translates to the given point.
| void QRegion::translate | ( | int | dx, |
| int | dy ) |
Translates (moves) the region dx along the X axis and dy along the Y axis.
Definition at line 3911 of file qregion.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a copy of the regtion that is translated {p}{.x()} along the x axis and {p}{.y()} along the y axis, relative to the current position. Positive values move the rectangle to the right and down.
|
nodiscard |
Returns a copy of the region that is translated dx along the x axis and dy along the y axis, relative to the current position. Positive values move the region to the right and down.
Definition at line 585 of file qregion.cpp.
Returns a region which is the union of this region and the given rect.
Definition at line 3983 of file qregion.cpp.
Returns a region which is the union of this region and r.
Region Union
The figure shows the union of two elliptical regions.
Definition at line 3920 of file qregion.cpp.
Returns a region which is the exclusive or (XOR) of this region and r.
Region XORed
The figure shows the exclusive or of two elliptical regions.
Definition at line 4140 of file qregion.cpp.
|
friend |
Writes the region r to the stream s and returns a reference to the stream.
Definition at line 311 of file qregion.cpp.
|
friend |
Reads a region from the stream s into r and returns a reference to the stream.
Definition at line 345 of file qregion.cpp.
|
friend |
|
friend |
Returns true if rect is guaranteed to be fully contained in region. A false return value does not guarantee the opposite.
Definition at line 4170 of file qregion.cpp.