QRectF Class Reference

QRectF Class Reference

#include <qrect.h>

Class Description

Definition at line 511 of file qrect.h.

Public Member Functions

 QRectF ()
 
 QRectF (const QPointF &topleft, const QSizeF &size)
 
 QRectF (const QPointF &topleft, const QPointF &bottomRight)
 
 QRectF (qreal left, qreal top, qreal width, qreal height)
 
 QRectF (const QRect &rect)
 
bool isNull () const
 
bool isEmpty () const
 
bool isValid () const
 
QRectF normalized () const
 
qreal left () const
 
qreal top () const
 
qreal right () const
 
qreal bottom () const
 
qreal x () const
 
qreal y () const
 
void setLeft (qreal pos)
 
void setTop (qreal pos)
 
void setRight (qreal pos)
 
void setBottom (qreal pos)
 
void setX (qreal pos)
 
void setY (qreal pos)
 
QPointF topLeft () const
 
QPointF bottomRight () const
 
QPointF topRight () const
 
QPointF bottomLeft () const
 
QPointF center () const
 
void setTopLeft (const QPointF &p)
 
void setBottomRight (const QPointF &p)
 
void setTopRight (const QPointF &p)
 
void setBottomLeft (const QPointF &p)
 
void moveLeft (qreal pos)
 
void moveTop (qreal pos)
 
void moveRight (qreal pos)
 
void moveBottom (qreal pos)
 
void moveTopLeft (const QPointF &p)
 
void moveBottomRight (const QPointF &p)
 
void moveTopRight (const QPointF &p)
 
void moveBottomLeft (const QPointF &p)
 
void moveCenter (const QPointF &p)
 
void translate (qreal dx, qreal dy)
 
void translate (const QPointF &p)
 
QRectF translated (qreal dx, qreal dy) const
 
QRectF translated (const QPointF &p) const
 
void moveTo (qreal x, qreal t)
 
void moveTo (const QPointF &p)
 
void setRect (qreal x, qreal y, qreal w, qreal h)
 
void getRect (qreal *x, qreal *y, qreal *w, qreal *h) const
 
void setCoords (qreal x1, qreal y1, qreal x2, qreal y2)
 
void getCoords (qreal *x1, qreal *y1, qreal *x2, qreal *y2) const
 
void adjust (qreal x1, qreal y1, qreal x2, qreal y2)
 
QRectF adjusted (qreal x1, qreal y1, qreal x2, qreal y2) const
 
QSizeF size () const
 
qreal width () const
 
qreal height () const
 
void setWidth (qreal w)
 
void setHeight (qreal h)
 
void setSize (const QSizeF &s)
 
QRectF operator| (const QRectF &r) const
 
QRectF operator& (const QRectF &r) const
 
QRectFoperator|= (const QRectF &r)
 
QRectFoperator&= (const QRectF &r)
 
bool contains (const QPointF &p) const
 
bool contains (qreal x, qreal y) const
 
bool contains (const QRectF &r) const
 
QRectF unite (const QRectF &r) const
 
QRectF united (const QRectF &other) const
 
QRectF intersect (const QRectF &r) const
 
QRectF intersected (const QRectF &other) const
 
bool intersects (const QRectF &r) const
 
QRect toRect () const
 
QRect toAlignedRect () const
 

Friends

Q_CORE_EXPORT_INLINE bool operator== (const QRectF &, const QRectF &)
 
Q_CORE_EXPORT_INLINE bool operator!= (const QRectF &, const QRectF &)
 

Constructor & Destructor Documentation

QRectF ( )
inline

Definition at line 514 of file qrect.h.

514 { xp = yp = 0.; w = h = 0.; }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QRectF ( const QPointF topleft,
const QSizeF size 
)
inline

Definition at line 634 of file qrect.h.

635 {
636  xp = atopLeft.x();
637  yp = atopLeft.y();
638  w = asize.width();
639  h = asize.height();
640 }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QRectF ( const QPointF topleft,
const QPointF bottomRight 
)
inline

Definition at line 642 of file qrect.h.

643 {
644  xp = atopLeft.x();
645  yp = atopLeft.y();
646  w = abottomRight.x() - xp;
647  h = abottomRight.y() - yp;
648 }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QRectF ( qreal  left,
qreal  top,
qreal  width,
qreal  height 
)
inline

Definition at line 629 of file qrect.h.

630  : xp(aleft), yp(atop), w(awidth), h(aheight)
631 {
632 }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QRectF ( const QRect rect)
inline

Definition at line 650 of file qrect.h.

651  : xp(r.x()), yp(r.y()), w(r.width()), h(r.height())
652 {
653 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775

Member Function Documentation

bool isNull ( ) const
inline

Definition at line 655 of file qrect.h.

656 { return w == 0. && h == 0.; }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
bool isEmpty ( ) const
inline

Definition at line 658 of file qrect.h.

659 { return w <= 0. || h <= 0.; }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
bool isValid ( ) const
inline

Definition at line 661 of file qrect.h.

662 { return w > 0. && h > 0.; }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QRectF normalized ( ) const
qreal left ( ) const
inline

Definition at line 525 of file qrect.h.

525 { return xp; }
qreal top ( ) const
inline

Definition at line 526 of file qrect.h.

526 { return yp; }
qreal right ( ) const
inline

Definition at line 527 of file qrect.h.

527 { return xp + w; }
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
qreal bottom ( ) const
inline

Definition at line 528 of file qrect.h.

528 { return yp + h; }
int int int int int int h
Definition: GLee.h:10534
qreal x ( ) const
inline

Definition at line 664 of file qrect.h.

665 { return xp; }
qreal y ( ) const
inline

Definition at line 667 of file qrect.h.

668 { return yp; }
void setLeft ( qreal  pos)
inline

Definition at line 670 of file qrect.h.

670 { qreal diff = pos - xp; xp += diff; w -= diff; }
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void setTop ( qreal  pos)
inline

Definition at line 674 of file qrect.h.

674 { qreal diff = pos - yp; yp += diff; h -= diff; }
int int int int int int h
Definition: GLee.h:10534
void setRight ( qreal  pos)
inline

Definition at line 672 of file qrect.h.

672 { w = pos - xp; }
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void setBottom ( qreal  pos)
inline

Definition at line 676 of file qrect.h.

676 { h = pos - yp; }
int int int int int int h
Definition: GLee.h:10534
void setX ( qreal  pos)
inline

Definition at line 536 of file qrect.h.

536 { setLeft(pos); }
void setLeft(qreal pos)
Definition: qrect.h:670
void setY ( qreal  pos)
inline

Definition at line 537 of file qrect.h.

537 { setTop(pos); }
void setTop(qreal pos)
Definition: qrect.h:674
QPointF topLeft ( ) const
inline

Definition at line 539 of file qrect.h.

539 { return QPointF(xp, yp); }
QPointF bottomRight ( ) const
inline

Definition at line 540 of file qrect.h.

540 { return QPointF(xp+w, yp+h); }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QPointF topRight ( ) const
inline

Definition at line 541 of file qrect.h.

541 { return QPointF(xp+w, yp); }
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QPointF bottomLeft ( ) const
inline

Definition at line 542 of file qrect.h.

542 { return QPointF(xp, yp+h); }
int int int int int int h
Definition: GLee.h:10534
QPointF center ( ) const
inline

Definition at line 686 of file qrect.h.

687 { return QPointF(xp + w/2, yp + h/2); }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void setTopLeft ( const QPointF p)
inline

Definition at line 678 of file qrect.h.

678 { setLeft(p.x()); setTop(p.y()); }
qreal y() const
Definition: qpoint.h:287
void setTop(qreal pos)
Definition: qrect.h:674
qreal x() const
Definition: qpoint.h:282
void setLeft(qreal pos)
Definition: qrect.h:670
void setBottomRight ( const QPointF p)
inline

Definition at line 684 of file qrect.h.

684 { setRight(p.x()); setBottom(p.y()); }
void setBottom(qreal pos)
Definition: qrect.h:676
qreal y() const
Definition: qpoint.h:287
void setRight(qreal pos)
Definition: qrect.h:672
qreal x() const
Definition: qpoint.h:282
void setTopRight ( const QPointF p)
inline

Definition at line 680 of file qrect.h.

680 { setRight(p.x()); setTop(p.y()); }
qreal y() const
Definition: qpoint.h:287
void setRight(qreal pos)
Definition: qrect.h:672
void setTop(qreal pos)
Definition: qrect.h:674
qreal x() const
Definition: qpoint.h:282
void setBottomLeft ( const QPointF p)
inline

Definition at line 682 of file qrect.h.

682 { setLeft(p.x()); setBottom(p.y()); }
void setBottom(qreal pos)
Definition: qrect.h:676
qreal y() const
Definition: qpoint.h:287
qreal x() const
Definition: qpoint.h:282
void setLeft(qreal pos)
Definition: qrect.h:670
void moveLeft ( qreal  pos)
inline

Definition at line 689 of file qrect.h.

689 { xp = pos; }
void moveTop ( qreal  pos)
inline

Definition at line 691 of file qrect.h.

691 { yp = pos; }
void moveRight ( qreal  pos)
inline

Definition at line 693 of file qrect.h.

693 { xp = pos - w; }
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void moveBottom ( qreal  pos)
inline

Definition at line 695 of file qrect.h.

695 { yp = pos - h; }
int int int int int int h
Definition: GLee.h:10534
void moveTopLeft ( const QPointF p)
inline

Definition at line 697 of file qrect.h.

697 { moveLeft(p.x()); moveTop(p.y()); }
void moveLeft(qreal pos)
Definition: qrect.h:689
qreal y() const
Definition: qpoint.h:287
qreal x() const
Definition: qpoint.h:282
void moveTop(qreal pos)
Definition: qrect.h:691
void moveBottomRight ( const QPointF p)
inline

Definition at line 703 of file qrect.h.

703 { moveRight(p.x()); moveBottom(p.y()); }
void moveRight(qreal pos)
Definition: qrect.h:693
void moveBottom(qreal pos)
Definition: qrect.h:695
qreal y() const
Definition: qpoint.h:287
qreal x() const
Definition: qpoint.h:282
void moveTopRight ( const QPointF p)
inline

Definition at line 699 of file qrect.h.

699 { moveRight(p.x()); moveTop(p.y()); }
void moveRight(qreal pos)
Definition: qrect.h:693
qreal y() const
Definition: qpoint.h:287
qreal x() const
Definition: qpoint.h:282
void moveTop(qreal pos)
Definition: qrect.h:691
void moveBottomLeft ( const QPointF p)
inline

Definition at line 701 of file qrect.h.

701 { moveLeft(p.x()); moveBottom(p.y()); }
void moveLeft(qreal pos)
Definition: qrect.h:689
void moveBottom(qreal pos)
Definition: qrect.h:695
qreal y() const
Definition: qpoint.h:287
qreal x() const
Definition: qpoint.h:282
void moveCenter ( const QPointF p)
inline

Definition at line 705 of file qrect.h.

705 { xp = p.x() - w/2; yp = p.y() - h/2; }
qreal y() const
Definition: qpoint.h:287
qreal x() const
Definition: qpoint.h:282
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void translate ( qreal  dx,
qreal  dy 
)
inline

Definition at line 716 of file qrect.h.

717 {
718  xp += dx;
719  yp += dy;
720 }
int int int int * dy
Definition: GLee.h:10535
int int int * dx
Definition: GLee.h:10535
void translate ( const QPointF p)
inline

Definition at line 722 of file qrect.h.

723 {
724  xp += p.x();
725  yp += p.y();
726 }
qreal y() const
Definition: qpoint.h:287
qreal x() const
Definition: qpoint.h:282
QRectF translated ( qreal  dx,
qreal  dy 
) const
inline

Definition at line 740 of file qrect.h.

741 { return QRectF(xp + dx, yp + dy, w, h); }
int int int int * dy
Definition: GLee.h:10535
int int int int int int h
Definition: GLee.h:10534
QRectF()
Definition: qrect.h:514
int int int * dx
Definition: GLee.h:10535
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QRectF translated ( const QPointF p) const
inline

Definition at line 743 of file qrect.h.

744 { return QRectF(xp + p.x(), yp + p.y(), w, h); }
qreal y() const
Definition: qpoint.h:287
qreal x() const
Definition: qpoint.h:282
int int int int int int h
Definition: GLee.h:10534
QRectF()
Definition: qrect.h:514
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void moveTo ( qreal  x,
qreal  t 
)
inline

Definition at line 728 of file qrect.h.

729 {
730  xp = ax;
731  yp = ay;
732 }
void moveTo ( const QPointF p)
inline

Definition at line 734 of file qrect.h.

735 {
736  xp = p.x();
737  yp = p.y();
738 }
qreal y() const
Definition: qpoint.h:287
qreal x() const
Definition: qpoint.h:282
void setRect ( qreal  x,
qreal  y,
qreal  w,
qreal  h 
)
inline

Definition at line 754 of file qrect.h.

755 {
756  this->xp = ax;
757  this->yp = ay;
758  this->w = aaw;
759  this->h = aah;
760 }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void getRect ( qreal *  x,
qreal *  y,
qreal *  w,
qreal *  h 
) const
inline

Definition at line 746 of file qrect.h.

747 {
748  *ax = this->xp;
749  *ay = this->yp;
750  *aaw = this->w;
751  *aah = this->h;
752 }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void setCoords ( qreal  x1,
qreal  y1,
qreal  x2,
qreal  y2 
)
inline

Definition at line 770 of file qrect.h.

771 {
772  xp = xp1;
773  yp = yp1;
774  w = xp2 - xp1;
775  h = yp2 - yp1;
776 }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void getCoords ( qreal *  x1,
qreal *  y1,
qreal *  x2,
qreal *  y2 
) const
inline

Definition at line 762 of file qrect.h.

763 {
764  *xp1 = xp;
765  *yp1 = yp;
766  *xp2 = xp + w;
767  *yp2 = yp + h;
768 }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void adjust ( qreal  x1,
qreal  y1,
qreal  x2,
qreal  y2 
)
inline

Definition at line 778 of file qrect.h.

779 { xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; }
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QRectF adjusted ( qreal  x1,
qreal  y1,
qreal  x2,
qreal  y2 
) const
inline

Definition at line 781 of file qrect.h.

782 { return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1); }
int int int int int int h
Definition: GLee.h:10534
QRectF()
Definition: qrect.h:514
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QSizeF size ( ) const
inline

Definition at line 713 of file qrect.h.

714 { return QSizeF(w, h); }
Definition: qsize.h:202
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
qreal width ( ) const
inline

Definition at line 707 of file qrect.h.

708 { return w; }
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
qreal height ( ) const
inline

Definition at line 710 of file qrect.h.

711 { return h; }
int int int int int int h
Definition: GLee.h:10534
void setWidth ( qreal  w)
inline

Definition at line 784 of file qrect.h.

785 { this->w = aw; }
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void setHeight ( qreal  h)
inline

Definition at line 787 of file qrect.h.

788 { this->h = ah; }
int int int int int int h
Definition: GLee.h:10534
void setSize ( const QSizeF s)
inline

Definition at line 790 of file qrect.h.

791 {
792  w = s.width();
793  h = s.height();
794 }
qreal height() const
Definition: qsize.h:287
int int int int int int h
Definition: GLee.h:10534
qreal width() const
Definition: qsize.h:284
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QRectF operator| ( const QRectF r) const
QRectF operator& ( const QRectF r) const
QRectF & operator|= ( const QRectF r)
inline

Definition at line 801 of file qrect.h.

802 {
803  *this = *this | r;
804  return *this;
805 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
QRectF & operator&= ( const QRectF r)
inline

Definition at line 807 of file qrect.h.

808 {
809  *this = *this & r;
810  return *this;
811 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
bool contains ( const QPointF p) const
bool contains ( qreal  x,
qreal  y 
) const
inline

Definition at line 796 of file qrect.h.

797 {
798  return contains(QPointF(ax, ay));
799 }
bool contains(const QPointF &p) const
bool contains ( const QRectF r) const
QRectF unite ( const QRectF r) const
inline

Definition at line 823 of file qrect.h.

824 {
825  return *this | r;
826 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
QRectF united ( const QRectF other) const
inline

Definition at line 828 of file qrect.h.

829 {
830  return unite(r);
831 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
QRectF unite(const QRectF &r) const
Definition: qrect.h:823
QRectF intersect ( const QRectF r) const
inline

Definition at line 813 of file qrect.h.

814 {
815  return *this & r;
816 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
QRectF intersected ( const QRectF other) const
inline

Definition at line 818 of file qrect.h.

819 {
820  return intersect(r);
821 }
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
QRectF intersect(const QRectF &r) const
Definition: qrect.h:813
bool intersects ( const QRectF r) const
QRect toRect ( ) const
inline

Definition at line 845 of file qrect.h.

846 {
847  return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h));
848 }
Definition: qrect.h:58
int int int int int int h
Definition: GLee.h:10534
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
QRect toAlignedRect ( ) const

Friends And Related Function Documentation

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

Definition at line 833 of file qrect.h.

834 {
835  return qFuzzyCompare(r1.xp, r2.xp) && qFuzzyCompare(r1.yp, r2.yp)
836  && qFuzzyCompare(r1.w, r2.w) && qFuzzyCompare(r1.h, r2.h);
837 }
bool qFuzzyCompare(const QMatrix &m1, const QMatrix &m2)
Definition: qmatrix.h:172
Q_CORE_EXPORT_INLINE bool operator!= ( const QRectF r1,
const QRectF r2 
)
friend

Definition at line 839 of file qrect.h.

840 {
841  return !qFuzzyCompare(r1.xp, r2.xp) || !qFuzzyCompare(r1.yp, r2.yp)
842  || !qFuzzyCompare(r1.w, r2.w) || !qFuzzyCompare(r1.h, r2.h);
843 }
bool qFuzzyCompare(const QMatrix &m1, const QMatrix &m2)
Definition: qmatrix.h:172

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