Eneboo - Documentación para desarrolladores
Métodos públicos | Amigas | Funciones relacionadas
Referencia de la Clase QRect

The QRect class defines a rectangle in the plane. Más...

#include <qrect.h>

Diagrama de herencias de QRect
QwtPolygonClipper QwtRect

Lista de todos los miembros.

Métodos públicos

 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
QRect normalize () const
int left () const
int top () const
int right () const
int bottom () const
QCOORDrLeft ()
QCOORDrTop ()
QCOORDrRight ()
QCOORDrBottom ()
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 rect (int *x, int *y, int *w, int *h) const
void coords (int *x1, int *y1, int *x2, int *y2) 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 moveBy (int dx, int dy)
void setRect (int x, int y, int w, int h)
void setCoords (int x1, int y1, int x2, int y2)
void addCoords (int x1, int y1, int x2, int y2)
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
QRectoperator|= (const QRect &r)
QRectoperator&= (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 intersect (const QRect &r) const
bool intersects (const QRect &r) const
 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
QRect normalize () const
int left () const
int top () const
int right () const
int bottom () const
QCOORDrLeft ()
QCOORDrTop ()
QCOORDrRight ()
QCOORDrBottom ()
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 rect (int *x, int *y, int *w, int *h) const
void coords (int *x1, int *y1, int *x2, int *y2) 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 moveBy (int dx, int dy)
void setRect (int x, int y, int w, int h)
void setCoords (int x1, int y1, int x2, int y2)
void addCoords (int x1, int y1, int x2, int y2)
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
QRectoperator|= (const QRect &r)
QRectoperator&= (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 intersect (const QRect &r) const
bool intersects (const QRect &r) const

Amigas

Q_EXPORT bool operator== (const QRect &, const QRect &)
Q_EXPORT bool operator!= (const QRect &, const QRect &)
Q_EXPORT bool operator== (const QRect &, const QRect &)
Q_EXPORT bool operator!= (const QRect &, const QRect &)

Funciones relacionadas

(Observar que estas no son funciones miembro.)

QDataStreamoperator<< (QDataStream &s, const QRect &r)
QDataStreamoperator>> (QDataStream &s, QRect &r)

Descripción detallada

The QRect class defines a rectangle in the plane.

A rectangle is internally represented as an upper-left corner and a bottom-right corner, but it is normally expressed as an upper-left corner and a size.

The coordinate type is QCOORD (defined in qwindowdefs.h as int). The minimum value of QCOORD is QCOORD_MIN (-2147483648) and the maximum value is QCOORD_MAX (2147483647).

Note that the size (width and height) of a rectangle might be different from what you are used to. If the top-left corner and the bottom-right corner are the same, the height and the width of the rectangle will both be 1.

Generally, {width = right - left + 1} and {height = bottom - top + 1}. We designed it this way to make it correspond to rectangular spaces used by drawing functions in which the width and height denote a number of pixels. For example, drawing a rectangle with width and height 1 draws a single pixel.

The default coordinate system has origin (0, 0) in the top-left corner. The positive direction of the y axis is down, and the positive x axis is from left to right.

A QRect can be constructed with a set of left, top, width and height integers, from two QPoints or from a QPoint and a QSize. After creation the dimensions can be changed, e.g. with setLeft(), setRight(), setTop() and setBottom(), or by setting sizes, e.g. setWidth(), setHeight() and setSize(). The dimensions can also be changed with the move functions, e.g. moveBy(), moveCenter(), moveBottomRight(), etc. You can also add coordinates to a rectangle with addCoords().

You can test to see if a QRect contains a specific point with contains(). You can also test to see if two QRects intersect with intersects() (see also intersect()). To get the bounding rectangle of two QRects use unite().

Ver también:
QPoint, QSize

Documentación del constructor y destructor

QRect::QRect ( ) [inline]

Constructs an invalid rectangle.

QRect::QRect ( const QPoint topLeft,
const QPoint bottomRight 
)

Constructs a rectangle with topLeft as the top-left corner and bottomRight as the bottom-right corner.

QRect::QRect ( const QPoint topLeft,
const QSize size 
)

Constructs a rectangle with topLeft as the top-left corner and size as the rectangle size.

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

Constructs a rectangle with the top, left corner and width and height.

Example (creates three identical rectangles):

        QRect r1( QPoint(100,200), QPoint(110,215) );
        QRect r2( QPoint(100,200), QSize(11,16) );
        QRect r3( 100, 200, 11, 16 );
QRect::QRect ( ) [inline]
QRect::QRect ( const QPoint topleft,
const QPoint bottomright 
)
QRect::QRect ( const QPoint topleft,
const QSize size 
)
QRect::QRect ( int  left,
int  top,
int  width,
int  height 
)

Documentación de las funciones miembro

void QRect::addCoords ( int  xp1,
int  yp1,
int  xp2,
int  yp2 
)

Adds xp1, yp1, xp2 and yp2 respectively to the existing coordinates of the rectangle.

void QRect::addCoords ( int  x1,
int  y1,
int  x2,
int  y2 
)
int QRect::bottom ( ) const [inline]

Returns the bottom coordinate of the rectangle.

Ver también:
setBottom(), top(), bottomLeft(), bottomRight()
int QRect::bottom ( ) const
QPoint QRect::bottomLeft ( ) const
QPoint QRect::bottomLeft ( ) const [inline]

Returns the bottom-left position of the rectangle.

Ver también:
setBottomLeft(), moveBottomLeft(), topRight(), bottom(), left()
QPoint QRect::bottomRight ( ) const
QPoint QRect::bottomRight ( ) const [inline]

Returns the bottom-right position of the rectangle.

Ver también:
setBottomRight(), moveBottomRight(), topLeft(), right(), bottom()
QPoint QRect::center ( ) const
QPoint QRect::center ( ) const [inline]

Returns the center point of the rectangle.

Ver también:
moveCenter(), topLeft(), bottomRight(), topRight(), bottomLeft()
bool QRect::contains ( int  x,
int  y 
) const
bool QRect::contains ( const QRect r,
bool  proper = FALSE 
) const
bool QRect::contains ( const QPoint p,
bool  proper = FALSE 
) const

Returns TRUE if the point p is inside or on the edge of the rectangle; otherwise returns FALSE.

If proper is TRUE, this function returns TRUE only if p is inside (not on the edge).

bool QRect::contains ( int  x,
int  y 
) const [inline]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

Returns TRUE if the point x, y is inside this rectangle; otherwise returns FALSE.

bool QRect::contains ( int  x,
int  y,
bool  proper 
) const [inline]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

Returns TRUE if the point x, y is inside this rectangle; otherwise returns FALSE.

If proper is TRUE, this function returns TRUE only if the point is entirely inside (not on the edge).

bool QRect::contains ( const QRect r,
bool  proper = FALSE 
) const

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Returns TRUE if the rectangle r is inside this rectangle; otherwise returns FALSE.

If proper is TRUE, this function returns TRUE only if r is entirely inside (not on the edge).

Ver también:
unite(), intersect(), intersects()
bool QRect::contains ( const QPoint p,
bool  proper = FALSE 
) const
bool QRect::contains ( int  x,
int  y,
bool  proper 
) const
void QRect::coords ( int x1,
int y1,
int x2,
int y2 
) const
void QRect::coords ( int xp1,
int yp1,
int xp2,
int yp2 
) const

Extracts the rectangle parameters as the top-left point *xp1, *yp1 and the bottom-right point *xp2, *yp2.

Ver también:
setCoords(), rect()
int QRect::height ( ) const [inline]

Returns the height of the rectangle. The height includes both the top and bottom edges, i.e. height = bottom - top + 1.

Ver también:
width(), size(), setHeight()
int QRect::height ( ) const
QRect QRect::intersect ( const QRect r) const

Returns the intersection of this rectangle and rectangle r. {r.intersect(s)} is equivalent to {r&s}.

QRect QRect::intersect ( const QRect r) const
bool QRect::intersects ( const QRect r) const
bool QRect::intersects ( const QRect r) const

Returns TRUE if this rectangle intersects with rectangle r (there is at least one pixel that is within both rectangles); otherwise returns FALSE.

Ver también:
intersect(), contains()
bool QRect::isEmpty ( void  ) const [inline]

Returns TRUE if the rectangle is empty; otherwise returns FALSE.

An empty rectangle has a left() > right() or top() > bottom().

An empty rectangle is not valid. {isEmpty() == !isValid()}

Ver también:
isNull(), isValid(), normalize()
bool QRect::isEmpty ( ) const
bool QRect::isNull ( ) const [inline]

Returns TRUE if the rectangle is a null rectangle; otherwise returns FALSE.

A null rectangle has both the width and the height set to 0, that is right() == left() - 1 and bottom() == top() - 1.

Note that if right() == left() and bottom() == top(), then the rectangle has width 1 and height 1.

A null rectangle is also empty.

A null rectangle is not valid.

Ver también:
isEmpty(), isValid()
bool QRect::isNull ( ) const
bool QRect::isValid ( ) const
bool QRect::isValid ( void  ) const [inline]

Returns TRUE if the rectangle is valid; otherwise returns FALSE.

A valid rectangle has a left() <= right() and top() <= bottom().

Note that non-trivial operations like intersections are not defined for invalid rectangles.

{isValid() == !isEmpty()}

Ver también:
isNull(), isEmpty(), normalize()
int QRect::left ( ) const
int QRect::left ( ) const [inline]

Returns the left coordinate of the rectangle. Identical to x().

Ver también:
setLeft(), right(), topLeft(), bottomLeft()
void QRect::moveBottom ( int  pos)

Sets the bottom position of the rectangle to pos, leaving the size unchanged.

Ver también:
bottom(), setBottom(), moveLeft(), moveTop(), moveRight()
void QRect::moveBottom ( int  pos)
void QRect::moveBottomLeft ( const QPoint p)

Sets the bottom-left position of the rectangle to p, leaving the size unchanged.

Ver también:
bottomLeft(), setBottomLeft(), moveTopLeft(), moveBottomRight(), moveTopRight()
void QRect::moveBottomLeft ( const QPoint p)
void QRect::moveBottomRight ( const QPoint p)

Sets the bottom-right position of the rectangle to p, leaving the size unchanged.

Ver también:
bottomRight(), setBottomRight(), moveTopLeft(), moveTopRight(), moveBottomLeft()
void QRect::moveBottomRight ( const QPoint p)
void QRect::moveBy ( int  dx,
int  dy 
)

Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position. Positive values move the rectangle to the right and down.

Ver también:
moveTopLeft()
void QRect::moveBy ( int  dx,
int  dy 
)
void QRect::moveCenter ( const QPoint p)

Sets the center point of the rectangle to p, leaving the size unchanged.

Ver también:
center(), moveTopLeft(), moveBottomRight(), moveTopRight(), moveBottomLeft()
void QRect::moveCenter ( const QPoint p)
void QRect::moveLeft ( int  pos)

Sets the left position of the rectangle to pos, leaving the size unchanged.

Ver también:
left(), setLeft(), moveTop(), moveRight(), moveBottom()
void QRect::moveLeft ( int  pos)
void QRect::moveRight ( int  pos)

Sets the right position of the rectangle to pos, leaving the size unchanged.

Ver también:
right(), setRight(), moveLeft(), moveTop(), moveBottom()
void QRect::moveRight ( int  pos)
void QRect::moveTop ( int  pos)

Sets the top position of the rectangle to pos, leaving the size unchanged.

Ver también:
top(), setTop(), moveLeft(), moveRight(), moveBottom()
void QRect::moveTop ( int  pos)
void QRect::moveTopLeft ( const QPoint p)

Sets the top-left position of the rectangle to p, leaving the size unchanged.

Ver también:
topLeft(), setTopLeft(), moveBottomRight(), moveTopRight(), moveBottomLeft()
void QRect::moveTopLeft ( const QPoint p)
void QRect::moveTopRight ( const QPoint p)

Sets the top-right position of the rectangle to p, leaving the size unchanged.

Ver también:
topRight(), setTopRight(), moveTopLeft(), moveBottomRight(), moveBottomLeft()
void QRect::moveTopRight ( const QPoint p)
QRect QRect::normalize ( ) const
QRect QRect::normalize ( ) const

Returns a normalized rectangle, i.e. a rectangle that has a non-negative width and height.

It swaps left and right if left() > right(), and swaps top and bottom if top() > bottom().

Ver también:
isValid()
QRect QRect::operator& ( const QRect r) const

Returns the intersection of this rectangle and rectangle r.

Returns an empty rectangle if there is no intersection.

Ver también:
operator&=(), operator|(), isEmpty(), intersects(), contains()
QRect QRect::operator& ( const QRect r) const
QRect & QRect::operator&= ( const QRect r)

Intersects this rectangle with rectangle r.

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

Returns the bounding rectangle of this rectangle and rectangle r.

The bounding rectangle of a nonempty rectangle and an empty or invalid rectangle is defined to be the nonempty rectangle.

Ver también:
operator|=(), operator&(), intersects(), contains()
QRect QRect::operator| ( const QRect r) const
QRect & QRect::operator|= ( const QRect r)

Unites this rectangle with rectangle r.

QRect& QRect::operator|= ( const QRect r)
QCOORD& QRect::rBottom ( )
QCOORD & QRect::rBottom ( ) [inline]

Returns a reference to the bottom coordinate of the rectangle.

Ver también:
rLeft(), rTop(), rRight()
void QRect::rect ( int x,
int y,
int w,
int h 
) const
void QRect::rect ( int x,
int y,
int w,
int h 
) const

Extracts the rectangle parameters as the position *x, *y and width *w and height *h.

Ver también:
setRect(), coords()
int QRect::right ( ) const
int QRect::right ( ) const [inline]

Returns the right coordinate of the rectangle.

Ver también:
setRight(), left(), topRight(), bottomRight()
QCOORD& QRect::rLeft ( )
QCOORD & QRect::rLeft ( ) [inline]

Returns a reference to the left coordinate of the rectangle.

Ver también:
rTop(), rRight(), rBottom()
QCOORD& QRect::rRight ( )
QCOORD & QRect::rRight ( ) [inline]

Returns a reference to the right coordinate of the rectangle.

Ver también:
rLeft(), rTop(), rBottom()
QCOORD& QRect::rTop ( )
QCOORD & QRect::rTop ( ) [inline]

Returns a reference to the top coordinate of the rectangle.

Ver también:
rLeft(), rRight(), rBottom()
void QRect::setBottom ( int  pos)
void QRect::setBottom ( int  pos) [inline]

Sets the bottom edge of the rectangle to pos. May change the height, but will never change the top edge of the rectangle.

Ver también:
bottom(), setTop(), setHeight()
void QRect::setBottomLeft ( const QPoint p)
void QRect::setBottomLeft ( const QPoint p)

Set the bottom-left corner of the rectangle to p. May change the size, but will the never change the top-right corner of the rectangle.

Ver también:
bottomLeft(), moveBottomLeft(), setTopLeft(), setBottomRight(), setTopRight()
void QRect::setBottomRight ( const QPoint p)

Set the bottom-right corner of the rectangle to p. May change the size, but will the never change the top-left corner of the rectangle.

Ver también:
bottomRight(), moveBottomRight(), setTopLeft(), setTopRight(), setBottomLeft()
void QRect::setBottomRight ( const QPoint p)
void QRect::setCoords ( int  xp1,
int  yp1,
int  xp2,
int  yp2 
)

Sets the coordinates of the rectangle's top-left corner to (xp1, yp1), and the coordinates of its bottom-right corner to (xp2, yp2).

Ver también:
coords(), setRect()
void QRect::setCoords ( int  x1,
int  y1,
int  x2,
int  y2 
)
void QRect::setHeight ( int  h)

Sets the height of the rectangle to h. The top edge is not moved, but the bottom edge may be moved.

Ver también:
height(), setTop(), setBottom(), setSize()
void QRect::setHeight ( int  h)
void QRect::setLeft ( int  pos) [inline]

Sets the left edge of the rectangle to pos. May change the width, but will never change the right edge of the rectangle.

Identical to setX().

Ver también:
left(), setTop(), setWidth()
void QRect::setLeft ( int  pos)
void QRect::setRect ( int  x,
int  y,
int  w,
int  h 
)
void QRect::setRect ( int  x,
int  y,
int  w,
int  h 
)

Sets the coordinates of the rectangle's top-left corner to (x, y), and its size to (w, h).

Ver también:
rect(), setCoords()
void QRect::setRight ( int  pos) [inline]

Sets the right edge of the rectangle to pos. May change the width, but will never change the left edge of the rectangle.

Ver también:
right(), setLeft(), setWidth()
void QRect::setRight ( int  pos)
void QRect::setSize ( const QSize s)
void QRect::setSize ( const QSize s)

Sets the size of the rectangle to s. The top-left corner is not moved.

Ver también:
size(), setWidth(), setHeight()
void QRect::setTop ( int  pos)
void QRect::setTop ( int  pos) [inline]

Sets the top edge of the rectangle to pos. May change the height, but will never change the bottom edge of the rectangle.

Identical to setY().

Ver también:
top(), setBottom(), setHeight()
void QRect::setTopLeft ( const QPoint p)

Set the top-left corner of the rectangle to p. May change the size, but will the never change the bottom-right corner of the rectangle.

Ver también:
topLeft(), moveTopLeft(), setBottomRight(), setTopRight(), setBottomLeft()
void QRect::setTopLeft ( const QPoint p)
void QRect::setTopRight ( const QPoint p)
void QRect::setTopRight ( const QPoint p)

Set the top-right corner of the rectangle to p. May change the size, but will the never change the bottom-left corner of the rectangle.

Ver también:
topRight(), moveTopRight(), setTopLeft(), setBottomRight(), setBottomLeft()
void QRect::setWidth ( int  w)
void QRect::setWidth ( int  w)

Sets the width of the rectangle to w. The right edge is changed, but not the left edge.

Ver también:
width(), setLeft(), setRight(), setSize()
void QRect::setX ( int  x) [inline]

Sets the x position of the rectangle (its left end) to x. May change the width, but will never change the right edge of the rectangle.

Identical to setLeft().

Ver también:
x(), setY()
void QRect::setX ( int  x)
void QRect::setY ( int  y) [inline]

Sets the y position of the rectangle (its top) to y. May change the height, but will never change the bottom edge of the rectangle.

Identical to setTop().

Ver también:
y(), setX()
void QRect::setY ( int  y)
QSize QRect::size ( ) const
QSize QRect::size ( ) const [inline]

Returns the size of the rectangle.

Ver también:
width(), height()
int QRect::top ( void  ) const [inline]

Returns the top coordinate of the rectangle. Identical to y().

Ver también:
setTop(), bottom(), topLeft(), topRight()
int QRect::top ( ) const
QPoint QRect::topLeft ( ) const [inline]

Returns the top-left position of the rectangle.

Ver también:
setTopLeft(), moveTopLeft(), bottomRight(), left(), top()
QPoint QRect::topLeft ( ) const
QPoint QRect::topRight ( ) const [inline]

Returns the top-right position of the rectangle.

Ver también:
setTopRight(), moveTopRight(), bottomLeft(), top(), right()
QPoint QRect::topRight ( ) const
QRect QRect::unite ( const QRect r) const

Returns the bounding rectangle of this rectangle and rectangle r. {r.unite(s)} is equivalent to {r|s}.

QRect QRect::unite ( const QRect r) const
int QRect::width ( ) const [inline]

Returns the width of the rectangle. The width includes both the left and right edges, i.e. width = right - left + 1.

Ver también:
height(), size(), setHeight()
int QRect::width ( ) const
int QRect::x ( ) const [inline]

Returns the left coordinate of the rectangle. Identical to left().

Ver también:
left(), y(), setX()
int QRect::x ( ) const
int QRect::y ( ) const [inline]

Returns the top coordinate of the rectangle. Identical to top().

Ver también:
top(), x(), setY()
int QRect::y ( ) const

Documentación de las funciones relacionadas y clases amigas

bool operator!= ( const QRect r1,
const QRect r2 
) [friend]

Returns TRUE if r1 and r2 are different; otherwise returns FALSE.

Q_EXPORT bool operator!= ( const QRect ,
const QRect  
) [friend]
QDataStream & operator<< ( QDataStream s,
const QRect r 
) [related]

Writes the QRect, r, to the stream s, and returns a reference to the stream.

Ver también:
Format of the QDataStream operators
bool operator== ( const QRect r1,
const QRect r2 
) [friend]

Returns TRUE if r1 and r2 are equal; otherwise returns FALSE.

Q_EXPORT bool operator== ( const QRect ,
const QRect  
) [friend]
QDataStream & operator>> ( QDataStream s,
QRect r 
) [related]

Reads a QRect from the stream s into rect r and returns a reference to the stream.

Ver también:
Format of the QDataStream operators

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'