QRegion is used with QPainter::setClipRegion() to limit the paint area to what needs to be painted. There is also a TQWidget::repaint() that takes a QRegion parameter. QRegion is the best tool for reducing flicker.
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 unite(), intersect(), subtract() or eor() (exclusive or). You can move a region using translate().
.PP
You can test whether a region isNull(), isEmpty() or if it contains() a QPoint or QRect. The bounding rectangle is given by boundingRect().
.PP
The function rects() gives a decomposition of the region into rectangles.
.PP
Example of using complex regions:
.PP
.nf
.br
void MyWidget::paintEvent( QPaintEvent * )
.br
{
.br
QPainter p; // our painter
.br
QRegion r1( QRect(100,100,200,80), // r1 = elliptic region
.br
QRegion::Ellipse );
.br
QRegion r2( QRect(100,120,90,30) ); // r2 = rectangular region
\fBWarning:\fR Due to window system limitations, the whole coordinate space for a region is limited to the points between -32767 and 32767 on Mac OS X and Windows 95/98/ME.
.PP
See also QPainter::setClipRegion(), QPainter::setClipRect(), Graphics Classes, and Image Processing Classes.
.SS "Member Type Documentation"
.SH "QRegion::RegionType"
Specifies the shape of the region to be created.
.TP
\fCQRegion::Rectangle\fR - the region covers the entire rectangle.
.TP
\fCQRegion::Ellipse\fR - the region is an ellipse inside the rectangle.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QRegion::QRegion ()"
Constructs a null region.
.PP
See also isNull().
.SH "QRegion::QRegion ( int x, int y, int w, int h, RegionType t = Rectangle )"
Constructs a rectangular or elliptic region.
.PP
If \fIt\fR is Rectangle, the region is the filled rectangle (\fIx\fR, \fIy\fR, \fIw\fR, \fIh\fR). If \fIt\fR is Ellipse, the region is the filled ellipse with center at (\fIx\fR + \fIw\fR / 2, \fIy\fR + \fIh\fR / 2) and size (\fIw\fR ,\fIh\fR ).
Constructs a polygon region from the point array \fIa\fR.
.PP
If \fIwinding\fR is TRUE, the polygon region is filled using the winding algorithm, otherwise the default even-odd fill algorithm is used.
.PP
This constructor may create complex regions that will slow down painting when used.
.SH "QRegion::QRegion ( const QRegion & r )"
Constructs a new region which is equal to region \fIr\fR.
.SH "QRegion::QRegion ( const QBitmap & bm )"
Constructs a region from the bitmap \fIbm\fR.
.PP
The resulting region consists of the pixels in bitmap \fIbm\fR that are \fCcolor1\fR, as if each pixel was a 1 by 1 rectangle.
.PP
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().
.SH "QRegion::~QRegion ()"
Destroys the region.
.SH "QRect QRegion::boundingRect () const"
Returns the bounding rectangle of this region. An empty region gives a rectangle that is QRect::isNull().
.SH "bool QRegion::contains ( const QPoint & p ) const"
Returns TRUE if the region contains the point \fIp\fR; otherwise returns FALSE.
.SH "bool QRegion::contains ( const QRect & r ) const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns TRUE if the region overlaps the rectangle \fIr\fR; otherwise returns FALSE.
.SH "QRegion QRegion::eor ( const QRegion & r ) const"
Returns a region which is the exclusive or (XOR) of this region and \fIr\fR.
.PP
<center>
.ce 1
.B "[Image Omitted]"
.PP
</center>
.PP
The figure shows the exclusive or of two elliptical regions.
.SH "HRGN QRegion::handle () const"
Returns the region's handle.
.SH "QRegion QRegion::intersect ( const QRegion & r ) const"
Returns a region which is the intersection of this region and \fIr\fR.
.PP
<center>
.ce 1
.B "[Image Omitted]"
.PP
</center>
.PP
The figure shows the intersection of two elliptical regions.
.SH "bool QRegion::isEmpty () const"
Returns TRUE if the region is empty; otherwise returns FALSE. An empty region is a region that contains no points.
.PP
Example:
.PP
.nf
.br
QRegion r1( 10, 10, 20, 20 );
.br
QRegion r2( 40, 40, 20, 20 );
.br
QRegion r3;
.br
r1.isNull(); // FALSE
.br
r1.isEmpty(); // FALSE
.br
r3.isNull(); // TRUE
.br
r3.isEmpty(); // TRUE
.br
r3 = r1.intersect( r2 ); // r3 = intersection of r1 and r2
.br
r3.isNull(); // FALSE
.br
r3.isEmpty(); // TRUE
.br
r3 = r1.unite( r2 ); // r3 = union of r1 and r2
.br
r3.isNull(); // FALSE
.br
r3.isEmpty(); // FALSE
.br
.fi
.PP
See also isNull().
.SH "bool QRegion::isNull () const"
Returns TRUE if the region is a null region; otherwise returns FALSE.
.PP
A null region is a region that has not been initialized. A null region is always empty.
.PP
See also isEmpty().
.SH "bool QRegion::operator!= ( const QRegion & r ) const"
Returns TRUE if the region is different from \fIr\fR; otherwise returns FALSE.
Applies the intersect() function to this region and \fIr\fR. \fCr1&r2\fR is equivalent to \fCr1.intersect(r2)\fR
.PP
See also intersect().
.SH "QRegion & QRegion::operator&= ( const QRegion & r )"
Applies the intersect() function to this region and \fIr\fR and assigns the result to this region. \fCr1&=r2\fR is equivalent to \fCr1=r1.intersect(r2)\fR
Applies the subtract() function to this region and \fIr\fR. \fCr1-r2\fR is equivalent to \fCr1.subtract(r2)\fR
.PP
See also subtract().
.SH "QRegion & QRegion::operator-= ( const QRegion & r )"
Applies the subtract() function to this region and \fIr\fR and assigns the result to this region. \fCr1-=r2\fR is equivalent to \fCr1=r1.subtract(r2)\fR
.PP
See also subtract().
.SH "QRegion & QRegion::operator= ( const QRegion & r )"
Assigns \fIr\fR to this region and returns a reference to the region.
.SH "bool QRegion::operator== ( const QRegion & r ) const"
Returns TRUE if the region is equal to \fIr\fR; otherwise returns FALSE.