QRegion(3qt)
πΈ QRegion π β the QRegion(3qt) manual, bestie edition β¨
okay so sit down, grab a strawberry π, because we're about to talk about QRegion and honestly? it's giving clip region for a painter energy and it ATE. π
β¨ NAME β¨
QRegion β clip region for a painter π¨
π¦ SYNOPSIS π¦
#include <qregion.h>
π Public Members
enum RegionType { Rectangle, Ellipse }
QRegion ()
QRegion ( int x, int y, int w, int h, RegionType t = Rectangle )
QRegion ( const QRect & r, RegionType t = Rectangle )
QRegion ( const QPointArray & a, bool winding = FALSE )
QRegion ( const QRegion & r )
QRegion ( const QBitmap & bm )
~QRegion ()
QRegion & operator= ( const QRegion & r )
bool isNull () const
bool isEmpty () const
bool contains ( const QPoint & p ) const
bool contains ( const QRect & r ) const
void translate ( int dx, int dy )
QRegion unite ( const QRegion & r ) const
QRegion intersect ( const QRegion & r ) const
QRegion subtract ( const QRegion & r ) const
QRegion eor ( const QRegion & r ) const
QRect boundingRect () const
QMemArray<QRect> rects () const
const QRegion operator| ( const QRegion & r ) const
const QRegion operator+ ( const QRegion & r ) const
const QRegion operator& ( const QRegion & r ) const
const QRegion operator- ( const QRegion & r ) const
const QRegion operator^ ( const QRegion & r ) const
QRegion & operator|= ( const QRegion & r )
QRegion & operator+= ( const QRegion & r )
QRegion & operator&= ( const QRegion & r )
QRegion & operator-= ( const QRegion & r )
QRegion & operator^= ( const QRegion & r )
bool operator== ( const QRegion & r ) const
bool operator!= ( const QRegion & r ) const
HRGN handle () const
π RELATED FUNCTION DOCUMENTATION π
QDataStream & operator<< ( QDataStream & s, const QRegion & r )
QDataStream & operator>> ( QDataStream & s, QRegion & r )
π DESCRIPTION π
The QRegion class specifies a clip region for a painter. periodt. β¨
QRegion is used with QPainter::setClipRegion() to limit the paint area to what needs to be painted. There's also a QWidget::repaint() that takes a QRegion parameter. QRegion is the best tool for reducing flicker. π₯ no cap, that's literally the whole point and she delivers.
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().
You can test whether a region isNull(), isEmpty() or if it contains() a QPoint or QRect. The bounding rectangle is given by boundingRect(). π
The function rects() gives a decomposition of the region into rectangles.
Example of using complex regions β look at her, she's serving:
void MyWidget::paintEvent( QPaintEvent * )
{
QPainter p; // our painter
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.intersect( r2 ); // r3 = intersection
p.begin( this ); // start painting widget
p.setClipRegion( r3 ); // set clip region
... // paint clipped graphics
p.end(); // painting done
}
QRegion is an implicitly shared class. π shared but make it lowkey efficient.
β οΈ Warning: Due to window system limitations, the whole coordinate space for a region is limited to the points between-32767and32767on Mac OS X and Windows 95/98/ME. π bestie do NOT go past those numbers, she will simply not vibe with it.
See also QPainter::setClipRegion(), QPainter::setClipRect(), Graphics Classes, and Image Processing Classes. π«Ά
π Member Type Documentation π
QRegion::RegionType
Specifies the shape of the region to be created. β¨
QRegion::Rectangleβ the region covers the entire rectangle.QRegion::Ellipseβ the region is an ellipse inside the rectangle.
π MEMBER FUNCTION DOCUMENTATION π
QRegion::QRegion ()
Constructs a null region.
See also isNull().
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 ).
QRegion::QRegion ( const QRect & r, RegionType t = Rectangle )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function. π
Create a region based on the rectange r with region type t.
If the rectangle is invalid a null region will be created. π
See also QRegion::RegionType.
QRegion::QRegion ( const QPointArray & a, bool winding = FALSE )
Constructs a polygon region from the point array a. π¦
If winding is TRUE, the polygon region is filled using the winding algorithm, otherwise the default even-odd fill algorithm is used.
β οΈ This constructor may create complex regions that will slow down painting when used. π₯ beautiful but expensive, iykyk.
QRegion::QRegion ( const QRegion & r )
Constructs a new region which is equal to region r. β¨
QRegion::QRegion ( const QBitmap & bm )
Constructs a region from the bitmap bm.
The resulting region consists of the pixels in bitmap bm that are 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(). π so maybe use that instead bestie.
QRegion::~QRegion ()
Destroys the region. π she's gone, she's resting.
QRect QRegion::boundingRect () const
Returns the bounding rectangle of this region. An empty region gives a rectangle that is QRect::isNull(). πΈ
bool QRegion::contains ( const QPoint & p ) const
Returns TRUE if the region contains the point p; otherwise returns FALSE. π
bool QRegion::contains ( const QRect & r ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function. β¨
Returns TRUE if the region overlaps the rectangle r; otherwise returns FALSE.
QRegion QRegion::eor ( const QRegion & r ) const
Returns a region which is the exclusive or (XOR) of this region and r. π₯
πΌοΈ [Image Omitted]
The figure shows the exclusive or of two elliptical regions. π
HRGN QRegion::handle () const
Returns the region's handle. π
QRegion QRegion::intersect ( const QRegion & r ) const
Returns a region which is the intersection of this region and r. π
πΌοΈ [Image Omitted]
The figure shows the intersection of two elliptical regions. β¨
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 β literally the vibe check, watch:
QRegion r1( 10, 10, 20, 20 );
QRegion r2( 40, 40, 20, 20 );
QRegion r3;
r1.isNull(); // FALSE
r1.isEmpty(); // FALSE
r3.isNull(); // TRUE
r3.isEmpty(); // TRUE
r3 = r1.intersect( r2 ); // r3 = intersection of r1 and r2
r3.isNull(); // FALSE
r3.isEmpty(); // TRUE
r3 = r1.unite( r2 ); // r3 = union of r1 and r2
r3.isNull(); // FALSE
r3.isEmpty(); // FALSE
See also isNull().
bool QRegion::isNull () const
Returns TRUE if the region is a null region; otherwise returns FALSE.
A null region is a region that has not been initialized. A null region is always empty. π
See also isEmpty().
bool QRegion::operator!= ( const QRegion & r ) const
Returns TRUE if the region is different from r; otherwise returns FALSE. π
not the same, not the vibe.
const QRegion QRegion::operator& ( const QRegion & r ) const
Applies the intersect() function to this region and r. r1&r2 is equivalent to r1.intersect(r2) β¨
See also intersect().
QRegion & QRegion::operator&= ( const QRegion & r )
Applies the intersect() function to this region and r and assigns the result to this region. r1&=r2 is equivalent to r1=r1.intersect(r2) π
See also intersect().
const QRegion QRegion::operator+ ( const QRegion & r ) const
Applies the unite() function to this region and r. r1+r2 is equivalent to r1.unite(r2) π₯
See also unite() and operator|().
QRegion & QRegion::operator+= ( const QRegion & r )
Applies the unite() function to this region and r and assigns the result to this region. r1+=r2 is equivalent to r1=r1.unite(r2) πΈ
See also intersect().
const QRegion QRegion::operator- ( const QRegion & r ) const
Applies the subtract() function to this region and r. r1-r2 is equivalent to r1.subtract(r2) π
See also subtract().
QRegion & QRegion::operator-= ( const QRegion & r )
Applies the subtract() function to this region and r and assigns the result to this region. r1-=r2 is equivalent to r1=r1.subtract(r2) β¨
See also subtract().
QRegion & QRegion::operator= ( const QRegion & r )
Assigns r to this region and returns a reference to the region. π she's copying her whole look, respectfully.
bool QRegion::operator== ( const QRegion & r ) const
Returns TRUE if the region is equal to r; otherwise returns FALSE. π
const QRegion QRegion::operator^ ( const QRegion & r ) const
Applies the eor() function to this region and r. r1^r2 is equivalent to r1.eor(r2) π₯
See also eor().
QRegion & QRegion::operator^= ( const QRegion & r )
Applies the eor() function to this region and r and assigns the result to this region. r1^=r2 is equivalent to r1=r1.eor(r2) π
See also eor().
const QRegion QRegion::operator| ( const QRegion & r ) const
Applies the unite() function to this region and r. r1|r2 is equivalent to r1.unite(r2) π
See also unite() and operator+().
QRegion & QRegion::operator|= ( const QRegion & r )
Applies the unite() function to this region and r and assigns the result to this region. r1|=r2 is equivalent to r1=r1.unite(r2) π
See also unite().
QMemArray<QRect> QRegion::rects () const
Returns an array of non-overlapping rectangles that make up the region. β¨
The union of all the rectangles is equal to the original region. π«Ά put them all together and you get her back, no notes.
QRegion QRegion::subtract ( const QRegion & r ) const
Returns a region which is r subtracted from this region. π
πΌοΈ [Image Omitted]
The figure shows the result when the ellipse on the right is subtracted from the ellipse on the left. (left-right )
void QRegion::translate ( int dx, int dy )
Translates (moves) the region dx along the X axis and dy along the Y axis. π¦ she's moving, she's going places.
QRegion QRegion::unite ( const QRegion & r ) const
Returns a region which is the union of this region and r. πΈ
πΌοΈ [Image Omitted]
The figure shows the union of two elliptical regions. β¨
π RELATED FUNCTION DOCUMENTATION π
QDataStream & operator<< ( QDataStream & s, const QRegion & r )
Writes the region r to the stream s and returns a reference to the stream. π
See also Format of the QDataStream operators.
QDataStream & operator>> ( QDataStream & s, QRegion & r )
Okay so this one is the read-in bestie of the stream operators π It takes the stream s, reads a region out of it, drops that region into r, and then returns a reference to the stream. That's it, that's the whole vibe. β¨
See also Format of the QDataStream operators. iykyk π«Ά
β¨ SEE ALSO β¨
π COPYRIGHT π
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. The legal tea is all in there, bestie, no cap. π
π AUTHOR π
Generated automatically from the source code. So yeah, no mysterious human author, just machine magic doing its little thing. π€β¨
π BUGS π
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. π«Ά
The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. Lowkey a cute lil side quest, but not the main character. πΈ
If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qregion.3qt) and the Qt version (3.3.8). That way the fix can actually find you. π
And that's the whole page, bestie! Brought to you by Trolltech AS, dated 2 February 2007, and it's QRegion(3qt). Slay, bye π β¨π
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms