QRect Class Reference

QRect Class Reference

#include <qrect.h>

Class Description

Definition at line 58 of file qrect.h.

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
 
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 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 &)
 
void qt_setCoords (QRect *r, int xp1, int yp1, int xp2, int yp2)
 

Constructor & Destructor Documentation

QRect ( )
inline

Definition at line 61 of file qrect.h.

61 { x1 = y1 = 0; x2 = y2 = -1; }
QRect ( const QPoint topleft,
const QPoint bottomright 
)
inline

Definition at line 215 of file qrect.h.

216 {
217  x1 = atopLeft.x();
218  y1 = atopLeft.y();
219  x2 = abottomRight.x();
220  y2 = abottomRight.y();
221 }
QRect ( const QPoint topleft,
const QSize size 
)
inline

Definition at line 223 of file qrect.h.

224 {
225  x1 = atopLeft.x();
226  y1 = atopLeft.y();
227  x2 = (x1+asize.width() - 1);
228  y2 = (y1+asize.height() - 1);
229 }
QRect ( int  left,
int  top,
int  width,
int  height 
)
inline

Definition at line 207 of file qrect.h.

208 {
209  x1 = aleft;
210  y1 = atop;
211  x2 = (aleft + awidth - 1);
212  y2 = (atop + aheight - 1);
213 }

Member Function Documentation

bool isNull ( ) const
inline

Definition at line 231 of file qrect.h.

232 { return x2 == x1 - 1 && y2 == y1 - 1; }
bool isEmpty ( ) const
inline

Definition at line 234 of file qrect.h.

235 { return x1 > x2 || y1 > y2; }
bool isValid ( ) const
inline

Definition at line 237 of file qrect.h.

238 { return x1 <= x2 && y1 <= y2; }
int left ( ) const
inline

Definition at line 240 of file qrect.h.

241 { return x1; }
int top ( ) const
inline

Definition at line 243 of file qrect.h.

244 { return y1; }
int right ( ) const
inline

Definition at line 246 of file qrect.h.

247 { return x2; }
int bottom ( ) const
inline

Definition at line 249 of file qrect.h.

250 { return y2; }
QRect normalized ( ) const
int x ( ) const
inline

Definition at line 252 of file qrect.h.

253 { return x1; }
int y ( ) const
inline

Definition at line 255 of file qrect.h.

256 { return y1; }
void setLeft ( int  pos)
inline

Definition at line 258 of file qrect.h.

259 { x1 = pos; }
void setTop ( int  pos)
inline

Definition at line 261 of file qrect.h.

262 { y1 = pos; }
void setRight ( int  pos)
inline

Definition at line 264 of file qrect.h.

265 { x2 = pos; }
void setBottom ( int  pos)
inline

Definition at line 267 of file qrect.h.

268 { y2 = pos; }
void setX ( int  x)
inline

Definition at line 282 of file qrect.h.

283 { x1 = ax; }
void setY ( int  y)
inline

Definition at line 285 of file qrect.h.

286 { y1 = ay; }
void setTopLeft ( const QPoint p)
inline

Definition at line 270 of file qrect.h.

271 { x1 = p.x(); y1 = p.y(); }
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
void setBottomRight ( const QPoint p)
inline

Definition at line 273 of file qrect.h.

274 { x2 = p.x(); y2 = p.y(); }
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
void setTopRight ( const QPoint p)
inline

Definition at line 276 of file qrect.h.

277 { x2 = p.x(); y1 = p.y(); }
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
void setBottomLeft ( const QPoint p)
inline

Definition at line 279 of file qrect.h.

280 { x1 = p.x(); y2 = p.y(); }
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
QPoint topLeft ( ) const
inline

Definition at line 288 of file qrect.h.

289 { return QPoint(x1, y1); }
Definition: qpoint.h:53
QPoint bottomRight ( ) const
inline

Definition at line 291 of file qrect.h.

292 { return QPoint(x2, y2); }
Definition: qpoint.h:53
QPoint topRight ( ) const
inline

Definition at line 294 of file qrect.h.

295 { return QPoint(x2, y1); }
Definition: qpoint.h:53
QPoint bottomLeft ( ) const
inline

Definition at line 297 of file qrect.h.

298 { return QPoint(x1, y2); }
Definition: qpoint.h:53
QPoint center ( ) const
inline

Definition at line 300 of file qrect.h.

301 { return QPoint((x1+x2)/2, (y1+y2)/2); }
Definition: qpoint.h:53
void moveLeft ( int  pos)
inline

Definition at line 350 of file qrect.h.

351 { x2 += (pos - x1); x1 = pos; }
void moveTop ( int  pos)
inline

Definition at line 353 of file qrect.h.

354 { y2 += (pos - y1); y1 = pos; }
void moveRight ( int  pos)
inline

Definition at line 356 of file qrect.h.

357 {
358  x1 += (pos - x2);
359  x2 = pos;
360 }
void moveBottom ( int  pos)
inline

Definition at line 362 of file qrect.h.

363 {
364  y1 += (pos - y2);
365  y2 = pos;
366 }
void moveTopLeft ( const QPoint p)
inline

Definition at line 368 of file qrect.h.

369 {
370  moveLeft(p.x());
371  moveTop(p.y());
372 }
void moveLeft(int pos)
Definition: qrect.h:350
void moveTop(int pos)
Definition: qrect.h:353
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
void moveBottomRight ( const QPoint p)
inline

Definition at line 374 of file qrect.h.

375 {
376  moveRight(p.x());
377  moveBottom(p.y());
378 }
void moveRight(int pos)
Definition: qrect.h:356
void moveBottom(int pos)
Definition: qrect.h:362
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
void moveTopRight ( const QPoint p)
inline

Definition at line 380 of file qrect.h.

381 {
382  moveRight(p.x());
383  moveTop(p.y());
384 }
void moveRight(int pos)
Definition: qrect.h:356
void moveTop(int pos)
Definition: qrect.h:353
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
void moveBottomLeft ( const QPoint p)
inline

Definition at line 386 of file qrect.h.

387 {
388  moveLeft(p.x());
389  moveBottom(p.y());
390 }
void moveLeft(int pos)
Definition: qrect.h:350
void moveBottom(int pos)
Definition: qrect.h:362
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
void moveCenter ( const QPoint p)
void translate ( int  dx,
int  dy 
)
inline

Definition at line 312 of file qrect.h.

313 {
314  x1 += dx;
315  y1 += dy;
316  x2 += dx;
317  y2 += dy;
318 }
int int int int * dy
Definition: GLee.h:10535
int int int * dx
Definition: GLee.h:10535
void translate ( const QPoint p)
inline

Definition at line 320 of file qrect.h.

321 {
322  x1 += p.x();
323  y1 += p.y();
324  x2 += p.x();
325  y2 += p.y();
326 }
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
QRect translated ( int  dx,
int  dy 
) const
inline

Definition at line 328 of file qrect.h.

329 { return QRect(QPoint(x1 + dx, y1 + dy), QPoint(x2 + dx, y2 + dy)); }
int int int int * dy
Definition: GLee.h:10535
Definition: qpoint.h:53
QRect()
Definition: qrect.h:61
int int int * dx
Definition: GLee.h:10535
QRect translated ( const QPoint p) const
inline

Definition at line 331 of file qrect.h.

332 { return QRect(QPoint(x1 + p.x(), y1 + p.y()), QPoint(x2 + p.x(), y2 + p.y())); }
Definition: qpoint.h:53
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
QRect()
Definition: qrect.h:61
void moveTo ( int  x,
int  t 
)
inline

Definition at line 334 of file qrect.h.

335 {
336  x2 += ax - x1;
337  y2 += ay - y1;
338  x1 = ax;
339  y1 = ay;
340 }
void moveTo ( const QPoint p)
inline

Definition at line 342 of file qrect.h.

343 {
344  x2 += p.x() - x1;
345  y2 += p.y() - y1;
346  x1 = p.x();
347  y1 = p.y();
348 }
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
void setRect ( int  x,
int  y,
int  w,
int  h 
)
inline

Definition at line 400 of file qrect.h.

401 {
402  x1 = ax;
403  y1 = ay;
404  x2 = (ax + aw - 1);
405  y2 = (ay + ah - 1);
406 }
void getRect ( int x,
int y,
int w,
int h 
) const
inline

Definition at line 392 of file qrect.h.

393 {
394  *ax = x1;
395  *ay = y1;
396  *aw = x2 - x1 + 1;
397  *ah = y2 - y1 + 1;
398 }
void setCoords ( int  x1,
int  y1,
int  x2,
int  y2 
)
inline

Definition at line 416 of file qrect.h.

417 {
418  x1 = xp1;
419  y1 = yp1;
420  x2 = xp2;
421  y2 = yp2;
422 }
void getCoords ( int x1,
int y1,
int x2,
int y2 
) const
inline

Definition at line 408 of file qrect.h.

409 {
410  *xp1 = x1;
411  *yp1 = y1;
412  *xp2 = x2;
413  *yp2 = y2;
414 }
void adjust ( int  x1,
int  y1,
int  x2,
int  y2 
)
inline

Definition at line 434 of file qrect.h.

435 {
436  x1 += dx1;
437  y1 += dy1;
438  x2 += dx2;
439  y2 += dy2;
440 }
QRect adjusted ( int  x1,
int  y1,
int  x2,
int  y2 
) const
inline

Definition at line 431 of file qrect.h.

432 { return QRect(QPoint(x1 + xp1, y1 + yp1), QPoint(x2 + xp2, y2 + yp2)); }
Definition: qpoint.h:53
QRect()
Definition: qrect.h:61
QSize size ( ) const
inline

Definition at line 309 of file qrect.h.

310 { return QSize(width(), height()); }
int height() const
Definition: qrect.h:306
int width() const
Definition: qrect.h:303
Definition: qsize.h:53
int width ( ) const
inline

Definition at line 303 of file qrect.h.

304 { return x2 - x1 + 1; }
int height ( ) const
inline

Definition at line 306 of file qrect.h.

307 { return y2 - y1 + 1; }
void setWidth ( int  w)
inline

Definition at line 442 of file qrect.h.

443 { x2 = (x1 + w - 1); }
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void setHeight ( int  h)
inline

Definition at line 445 of file qrect.h.

446 { y2 = (y1 + h - 1); }
int int int int int int h
Definition: GLee.h:10534
void setSize ( const QSize s)
inline

Definition at line 448 of file qrect.h.

449 {
450  x2 = (s.width() + x1 - 1);
451  y2 = (s.height() + y1 - 1);
452 }
int height() const
Definition: qsize.h:129
int width() const
Definition: qsize.h:126
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.

465 {
466  *this = *this | r;
467  return *this;
468 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
QRect & operator&= ( const QRect r)
inline

Definition at line 470 of file qrect.h.

471 {
472  *this = *this & r;
473  return *this;
474 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
bool contains ( const QPoint p,
bool  proper = false 
) const
bool contains ( int  x,
int  y 
) const
inline

Definition at line 459 of file qrect.h.

460 {
461  return contains(QPoint(ax, ay), false);
462 }
Definition: qpoint.h:53
bool contains(const QPoint &p, bool proper=false) const
bool contains ( int  x,
int  y,
bool  proper 
) const
inline

Definition at line 454 of file qrect.h.

455 {
456  return contains(QPoint(ax, ay), aproper);
457 }
Definition: qpoint.h:53
bool contains(const QPoint &p, bool proper=false) const
bool contains ( const QRect r,
bool  proper = false 
) const
QRect unite ( const QRect r) const
inline

Definition at line 486 of file qrect.h.

487 {
488  return *this | r;
489 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
QRect united ( const QRect other) const
inline

Definition at line 491 of file qrect.h.

492 {
493  return unite(r);
494 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
QRect unite(const QRect &r) const
Definition: qrect.h:486
QRect intersect ( const QRect r) const
inline

Definition at line 476 of file qrect.h.

477 {
478  return *this & r;
479 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
QRect intersected ( const QRect other) const
inline

Definition at line 481 of file qrect.h.

482 {
483  return intersect(other);
484 }
QRect intersect(const QRect &r) const
Definition: qrect.h:476
bool intersects ( const QRect r) const

Friends And Related Function Documentation

Q_CORE_EXPORT_INLINE bool operator== ( const QRect r1,
const QRect r2 
)
friend

Definition at line 496 of file qrect.h.

497 {
498  return r1.x1==r2.x1 && r1.x2==r2.x2 && r1.y1==r2.y1 && r1.y2==r2.y2;
499 }
Q_CORE_EXPORT_INLINE bool operator!= ( const QRect r1,
const QRect r2 
)
friend

Definition at line 501 of file qrect.h.

502 {
503  return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2;
504 }
void qt_setCoords ( QRect r,
int  xp1,
int  yp1,
int  xp2,
int  yp2 
)
friend

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