- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Friends

# QRect Class Reference

Search for all occurrences

## Detailed Description

Definition at line 58 of file qrect.h.

`#include <qrect.h>`

List of all members.

## Public Member Functions
| QRect ()
| QRect (const QPoint &topleft, const QPoint &bottomright)
| QRect (const QPoint &topleft, const QSize &size)
| QRect (int left, int top, int width, int height)
bool | isNull () const
bool | isEmpty () const
bool | isValid () const
int | left () const
int | top () const
int | right () const
int | bottom () const
QRect | normalized () const
int | x () const
int | y () const
void | setLeft (int pos)
void | setTop (int pos)
void | setRight (int pos)
void | setBottom (int pos)
void | setX (int x)
void | setY (int y)
void | setTopLeft (const QPoint &p)
void | setBottomRight (const QPoint &p)
void | setTopRight (const QPoint &p)
void | setBottomLeft (const QPoint &p)
QPoint | topLeft () const
QPoint | bottomRight () const
QPoint | topRight () const
QPoint | bottomLeft () const
QPoint | center () const
void | moveLeft (int pos)
void | moveTop (int pos)
void | moveRight (int pos)
void | moveBottom (int pos)
void | moveTopLeft (const QPoint &p)
void | moveBottomRight (const QPoint &p)
void | moveTopRight (const QPoint &p)
void | moveBottomLeft (const QPoint &p)
void | moveCenter (const QPoint &p)
void | translate (int dx, int dy)
void | translate (const QPoint &p)
QRect | translated (int dx, int dy) const
QRect | translated (const QPoint &p) const
void | moveTo (int x, int t)
void | moveTo (const QPoint &p)
void | setRect (int x, int y, int w, int h)
void | getRect (int *x, int *y, int *w, int *h) const
void | setCoords (int x1, int y1, int x2, int y2)
void | getCoords (int *x1, int *y1, int *x2, int *y2) const
void | adjust (int x1, int y1, int x2, int y2)
QRect | adjusted (int x1, int y1, int x2, int y2) const
QSize | size () const
int | width () const
int | height () const
void | setWidth (int w)
void | setHeight (int h)
void | setSize (const QSize &s)
QRect | operator| (const QRect &r) const
QRect | operator& (const QRect &r) const
QRect & | operator|= (const QRect &r)
QRect & | operator&= (const QRect &r)
bool | contains (const QPoint &p, bool proper=false) const
bool | contains (int x, int y) const
bool | contains (int x, int y, bool proper) const
bool | contains (const QRect &r, bool proper=false) const
QRect | unite (const QRect &r) const
QRect | united (const QRect &other) const
QRect | intersect (const QRect &r) const
QRect | intersected (const QRect &other) const
bool | intersects (const QRect &r) const
## Friends
Q_CORE_EXPORT_INLINE bool | operator== (const QRect &, const QRect &)
Q_CORE_EXPORT_INLINE bool | operator!= (const QRect &, const QRect &)

## Constructor & Destructor Documentation

QRect | ( |  | ) | `[inline]`

Definition at line 61 of file qrect.h.

    { x1 = y1 = 0; x2 = y2 = -1; }

QRect | ( | const QPoint & | topleft,
|  | const QPoint & | bottomright
| ) |  | `[inline]`

Definition at line 215 of file qrect.h.

    {
        x1 = atopLeft.x();
        y1 = atopLeft.y();
        x2 = abottomRight.x();
        y2 = abottomRight.y();
    }

QRect | ( | const QPoint & | topleft,
|  | const QSize & | size
| ) |  | `[inline]`

Definition at line 223 of file qrect.h.

    {
        x1 = atopLeft.x();
        y1 = atopLeft.y();
        x2 = (x1+asize.width() - 1);
        y2 = (y1+asize.height() - 1);
    }

QRect | ( | int | left,
|  | int | top,
|  | int | width,
|  | int | height
| ) |  | `[inline]`

Definition at line 207 of file qrect.h.

    {
        x1 = aleft;
        y1 = atop;
        x2 = (aleft + awidth - 1);
        y2 = (atop + aheight - 1);
    }

## Member Function Documentation

bool isNull | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 231 of file qrect.h.

    { return x2 == x1 - 1 && y2 == y1 - 1; }

bool isEmpty | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 234 of file qrect.h.

    { return x1 > x2 || y1 > y2; }

bool isValid | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 237 of file qrect.h.

    { return x1 <= x2 && y1 <= y2; }

int left | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 240 of file qrect.h.

    { return x1; }

int top | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 243 of file qrect.h.

    { return y1; }

int right | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 246 of file qrect.h.

    { return x2; }

int bottom | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 249 of file qrect.h.

    { return y2; }

QRect normalized | ( |  | ) | const

Search for all occurrences

int x | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 252 of file qrect.h.

    { return x1; }

int y | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 255 of file qrect.h.

    { return y1; }

void setLeft | ( | int | pos | ) | `[inline]`

Search for all occurrences

Definition at line 258 of file qrect.h.

    { x1 = pos; }

void setTop | ( | int | pos | ) | `[inline]`

Search for all occurrences

Definition at line 261 of file qrect.h.

    { y1 = pos; }

void setRight | ( | int | pos | ) | `[inline]`

Search for all occurrences

Definition at line 264 of file qrect.h.

    { x2 = pos; }

void setBottom | ( | int | pos | ) | `[inline]`

Search for all occurrences

Definition at line 267 of file qrect.h.

    { y2 = pos; }

void setX | ( | int | x | ) | `[inline]`

Search for all occurrences

Definition at line 282 of file qrect.h.

    { x1 = ax; }

void setY | ( | int | y | ) | `[inline]`

Search for all occurrences

Definition at line 285 of file qrect.h.

    { y1 = ay; }

void setTopLeft | ( | const QPoint & | p | ) | `[inline]`

Search for all occurrences

Definition at line 270 of file qrect.h.

    { x1 = p.x(); y1 = p.y(); }

void setBottomRight | ( | const QPoint & | p | ) | `[inline]`

Search for all occurrences

Definition at line 273 of file qrect.h.

    { x2 = p.x(); y2 = p.y(); }

void setTopRight | ( | const QPoint & | p | ) | `[inline]`

Search for all occurrences

Definition at line 276 of file qrect.h.

    { x2 = p.x(); y1 = p.y(); }

void setBottomLeft | ( | const QPoint & | p | ) | `[inline]`

Search for all occurrences

Definition at line 279 of file qrect.h.

    { x1 = p.x(); y2 = p.y(); }

QPoint topLeft | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 288 of file qrect.h.

    { return QPoint(x1, y1); }

QPoint bottomRight | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 291 of file qrect.h.

    { return QPoint(x2, y2); }

QPoint topRight | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 294 of file qrect.h.

    { return QPoint(x2, y1); }

QPoint bottomLeft | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 297 of file qrect.h.

    { return QPoint(x1, y2); }

QPoint center | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 300 of file qrect.h.

    { return QPoint((x1+x2)/2, (y1+y2)/2); }

void moveLeft | ( | int | pos | ) | `[inline]`

Search for all occurrences

Definition at line 350 of file qrect.h.

    { x2 += (pos - x1); x1 = pos; }

void moveTop | ( | int | pos | ) | `[inline]`

Search for all occurrences

Definition at line 353 of file qrect.h.

    { y2 += (pos - y1); y1 = pos; }

void moveRight | ( | int | pos | ) | `[inline]`

Search for all occurrences

Definition at line 356 of file qrect.h.

    {
        x1 += (pos - x2);
        x2 = pos;
    }

void moveBottom | ( | int | pos | ) | `[inline]`

Search for all occurrences

Definition at line 362 of file qrect.h.

    {
        y1 += (pos - y2);
        y2 = pos;
    }

void moveTopLeft | ( | const QPoint & | p | ) | `[inline]`

Search for all occurrences

Definition at line 368 of file qrect.h.

    {
        moveLeft(p.x());
        moveTop(p.y());
    }

void moveBottomRight | ( | const QPoint & | p | ) | `[inline]`

Search for all occurrences

Definition at line 374 of file qrect.h.

    {
        moveRight(p.x());
        moveBottom(p.y());
    }

void moveTopRight | ( | const QPoint & | p | ) | `[inline]`

Search for all occurrences

Definition at line 380 of file qrect.h.

    {
        moveRight(p.x());
        moveTop(p.y());
    }

void moveBottomLeft | ( | const QPoint & | p | ) | `[inline]`

Search for all occurrences

Definition at line 386 of file qrect.h.

    {
        moveLeft(p.x());
        moveBottom(p.y());
    }

void moveCenter | ( | const QPoint & | p | ) |

Search for all occurrences

void translate | ( | int | dx,
|  | int | dy
| ) |  | `[inline]`

Search for all occurrences

Definition at line 312 of file qrect.h.

    {
        x1 += dx;
        y1 += dy;
        x2 += dx;
        y2 += dy;
    }

void translate | ( | const QPoint & | p | ) | `[inline]`

Search for all occurrences

Definition at line 320 of file qrect.h.

    {
        x1 += p.x();
        y1 += p.y();
        x2 += p.x();
        y2 += p.y();
    }

QRect translated | ( | int | dx,
|  | int | dy
| ) |  | const `[inline]`

Search for all occurrences

Definition at line 328 of file qrect.h.

    { return QRect(QPoint(x1 + dx, y1 + dy), QPoint(x2 + dx, y2 + dy)); }

QRect translated | ( | const QPoint & | p | ) | const `[inline]`

Search for all occurrences

Definition at line 331 of file qrect.h.

    { return QRect(QPoint(x1 + p.x(), y1 + p.y()), QPoint(x2 + p.x(), y2 + p.y())); }

void moveTo | ( | int | x,
|  | int | t
| ) |  | `[inline]`

Search for all occurrences

Definition at line 334 of file qrect.h.

    {
        x2 += ax - x1;
        y2 += ay - y1;
        x1 = ax;
        y1 = ay;
    }

void moveTo | ( | const QPoint & | p | ) | `[inline]`

Search for all occurrences

Definition at line 342 of file qrect.h.

    {
        x2 += p.x() - x1;
        y2 += p.y() - y1;
        x1 = p.x();
        y1 = p.y();
    }

void setRect | ( | int | x,
|  | int | y,
|  | int | w,
|  | int | h
| ) |  | `[inline]`

Search for all occurrences

Definition at line 400 of file qrect.h.

    {
        x1 = ax;
        y1 = ay;
        x2 = (ax + aw - 1);
        y2 = (ay + ah - 1);
    }

void getRect | ( | int * | x,
|  | int * | y,
|  | int * | w,
|  | int * | h
| ) |  | const `[inline]`

Search for all occurrences

Definition at line 392 of file qrect.h.

    {
        *ax = x1;
        *ay = y1;
        *aw = x2 - x1 + 1;
        *ah = y2 - y1 + 1;
    }

void setCoords | ( | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2
| ) |  | `[inline]`

Search for all occurrences

Definition at line 416 of file qrect.h.

    {
        x1 = xp1;
        y1 = yp1;
        x2 = xp2;
        y2 = yp2;
    }

void getCoords | ( | int * | x1,
|  | int * | y1,
|  | int * | x2,
|  | int * | y2
| ) |  | const `[inline]`

Search for all occurrences

Definition at line 408 of file qrect.h.

    {
        *xp1 = x1;
        *yp1 = y1;
        *xp2 = x2;
        *yp2 = y2;
    }

void adjust | ( | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2
| ) |  | `[inline]`

Search for all occurrences

Definition at line 434 of file qrect.h.

    {
        x1 += dx1;
        y1 += dy1;
        x2 += dx2;
        y2 += dy2;
    }

QRect adjusted | ( | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2
| ) |  | const `[inline]`

Search for all occurrences

Definition at line 431 of file qrect.h.

    { return QRect(QPoint(x1 + xp1, y1 + yp1), QPoint(x2 + xp2, y2 + yp2)); }

QSize size | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 309 of file qrect.h.

    { return QSize(width(), height()); }

int width | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 303 of file qrect.h.

    { return  x2 - x1 + 1; }

int height | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 306 of file qrect.h.

    { return  y2 - y1 + 1; }

void setWidth | ( | int | w | ) | `[inline]`

Search for all occurrences

Definition at line 442 of file qrect.h.

    { x2 = (x1 + w - 1); }

void setHeight | ( | int | h | ) | `[inline]`

Search for all occurrences

Definition at line 445 of file qrect.h.

    { y2 = (y1 + h - 1); }

void setSize | ( | const QSize & | s | ) | `[inline]`

Search for all occurrences

Definition at line 448 of file qrect.h.

    {
        x2 = (s.width()  + x1 - 1);
        y2 = (s.height() + y1 - 1);
    }

QRect operator| | ( | const QRect & | r | ) | const

QRect operator& | ( | const QRect & | r | ) | const

QRect & operator|= | ( | const QRect & | r | ) | `[inline]`

Definition at line 464 of file qrect.h.

    {
        *this = *this | r;
        return *this;
    }

QRect & operator&= | ( | const QRect & | r | ) | `[inline]`

Definition at line 470 of file qrect.h.

    {
        *this = *this & r;
        return *this;
    }

bool contains | ( | const QPoint & | p,
|  | bool | proper = `false`
| ) |  | const

Search for all occurrences

bool contains | ( | int | x,
|  | int | y
| ) |  | const `[inline]`

Search for all occurrences

Definition at line 459 of file qrect.h.

    {
        return contains(QPoint(ax, ay), false);
    }

bool contains | ( | int | x,
|  | int | y,
|  | bool | proper
| ) |  | const `[inline]`

Search for all occurrences

Definition at line 454 of file qrect.h.

    {
        return contains(QPoint(ax, ay), aproper);
    }

bool contains | ( | const QRect & | r,
|  | bool | proper = `false`
| ) |  | const

Search for all occurrences

QRect unite | ( | const QRect & | r | ) | const `[inline]`

Search for all occurrences

Definition at line 486 of file qrect.h.

    {
        return *this | r;
    }

QRect united | ( | const QRect & | other | ) | const `[inline]`

Search for all occurrences

Definition at line 491 of file qrect.h.

    {
         return unite(r);
    }

QRect intersect | ( | const QRect & | r | ) | const `[inline]`

Search for all occurrences

Definition at line 476 of file qrect.h.

    {
        return *this & r;
    }

QRect intersected | ( | const QRect & | other | ) | const `[inline]`

Search for all occurrences

Definition at line 481 of file qrect.h.

    {
        return intersect(other);
    }

bool intersects | ( | const QRect & | r | ) | const

Search for all occurrences

## Friends And Related Function Documentation

Q_CORE_EXPORT_INLINE bool operator== | ( | const QRect & | r1,
|  | const QRect & | r2
| ) |  | `[friend]`

Q_CORE_EXPORT_INLINE bool operator!= | ( | const QRect & | r1,
|  | const QRect & | r2
| ) |  | `[friend]`

The documentation for this class was generated from the following file:

- QtCore/qrect.h

QRect QRect QRect QRect QRect QRect QRect QRect QRect QRect
QRect QRect QRect QRect QRect QRect QRect QRect QRect QRect