43 #include <QtCore/qhashfunctions.h>
44 #include <QtCore/qmargins.h>
45 #include <QtCore/qsize.h>
46 #include <QtCore/qpoint.h>
49 #error qrect.h must be included before any header file that defines topLeft
52 #if defined(Q_OS_DARWIN) || defined(Q_QDOC)
66 constexpr
inline bool isNull()
const noexcept;
78 constexpr
inline void setLeft(
int pos) noexcept;
79 constexpr
inline void setTop(
int pos) noexcept;
80 constexpr
inline void setRight(
int pos) noexcept;
81 constexpr
inline void setBottom(
int pos) noexcept;
82 constexpr
inline void setX(
int x) noexcept;
83 constexpr
inline void setY(
int y) noexcept;
96 constexpr
inline void moveLeft(
int pos) noexcept;
97 constexpr
inline void moveTop(
int pos) noexcept;
98 constexpr
inline void moveRight(
int pos) noexcept;
99 constexpr
inline void moveBottom(
int pos) noexcept;
106 constexpr
inline void translate(
int dx,
int dy) noexcept;
108 [[nodiscard]] constexpr
inline QRect translated(
int dx,
int dy)
const noexcept;
112 constexpr
inline void moveTo(
int x,
int t) noexcept;
115 constexpr
inline void setRect(
int x,
int y,
int w,
int h) noexcept;
118 constexpr
inline void setCoords(
int x1,
int y1,
int x2,
int y2) noexcept;
121 constexpr
inline void adjust(
int x1,
int y1,
int x2,
int y2) noexcept;
127 constexpr
inline void setWidth(
int w) noexcept;
128 constexpr
inline void setHeight(
int h) noexcept;
155 friend constexpr
inline size_t qHash(
const QRect &,
size_t) noexcept;
157 #if defined(Q_OS_DARWIN) || defined(Q_QDOC)
158 [[nodiscard]] CGRect toCGRect()
const noexcept;
173 #ifndef QT_NO_DATASTREAM
182 constexpr
inline QRect::QRect(
int aleft,
int atop,
int awidth,
int aheight) noexcept
183 :
x1(aleft),
y1(atop),
x2(aleft + awidth - 1),
y2(atop + aheight - 1) {}
186 :
x1(atopLeft.x()),
y1(atopLeft.y()),
x2(abottomRight.x()),
y2(abottomRight.y()) {}
189 :
x1(atopLeft.x()),
y1(atopLeft.y()),
x2(atopLeft.x()+asize.width() - 1),
y2(atopLeft.y()+asize.height() - 1) {}
192 {
return x2 ==
x1 - 1 &&
y2 ==
y1 - 1; }
231 {
x1 =
p.x();
y1 =
p.y(); }
234 {
x2 =
p.x();
y2 =
p.y(); }
237 {
x2 =
p.x();
y1 =
p.y(); }
240 {
x1 =
p.x();
y2 =
p.y(); }
264 {
return x2 -
x1 + 1; }
267 {
return y2 -
y1 + 1; }
400 constexpr
inline void QRect::adjust(
int dx1,
int dy1,
int dx2,
int dy2) noexcept
409 {
x2 = (
x1 +
w - 1); }
412 {
y2 = (
y1 +
h - 1); }
416 x2 = (
s.width() +
x1 - 1);
417 y2 = (
s.height() +
y1 - 1);
444 return *
this &
other;
452 constexpr
inline size_t qHash(
const QRect &
r,
size_t seed = 0) noexcept
459 return QRect(
QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()),
460 QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom()));
465 return QRect(
QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()),
466 QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom()));
472 QPoint(lhs.right() -
rhs.right(), lhs.bottom() -
rhs.bottom()));
478 QPoint(
x2 + margins.right(),
y2 + margins.bottom()));
484 QPoint(
x2 - margins.right(),
y2 - margins.bottom()));
489 *
this = marginsAdded(margins);
495 *
this = marginsRemoved(margins);
505 #ifndef QT_NO_DEBUG_STREAM
513 constexpr
QRectF() noexcept : xp(0.), yp(0.),
w(0.),
h(0.) {}
519 constexpr
inline bool isNull()
const noexcept;
614 [[nodiscard]] constexpr
inline QRect toRect()
const noexcept;
615 [[nodiscard]]
QRect toAlignedRect()
const noexcept;
617 #if defined(Q_OS_DARWIN) || defined(Q_QDOC)
618 [[nodiscard]]
static QRectF fromCGRect(CGRect
rect) noexcept;
619 [[nodiscard]] CGRect toCGRect()
const noexcept;
634 #ifndef QT_NO_DATASTREAM
644 : xp(aleft), yp(atop),
w(awidth),
h(aheight)
649 : xp(atopLeft.x()), yp(atopLeft.y()),
w(asize.width()),
h(asize.height())
655 : xp(atopLeft.x()), yp(atopLeft.y()),
w(abottomRight.x() - atopLeft.x()),
h(abottomRight.y() - atopLeft.y())
660 : xp(
r.x()), yp(
r.y()),
w(
r.width()),
h(
r.height())
668 {
return w == 0. &&
h == 0.; }
671 {
return w <= 0. ||
h <= 0.; }
676 {
return w > 0. &&
h > 0.; }
685 {
qreal diff =
pos - xp; xp += diff;
w -= diff; }
691 {
qreal diff =
pos - yp; yp += diff;
h -= diff; }
697 { setLeft(
p.x()); setTop(
p.y()); }
700 { setRight(
p.x()); setTop(
p.y()); }
703 { setLeft(
p.x()); setBottom(
p.y()); }
706 { setRight(
p.x()); setBottom(
p.y()); }
724 { moveLeft(
p.x()); moveTop(
p.y()); }
727 { moveRight(
p.x()); moveTop(
p.y()); }
730 { moveLeft(
p.x()); moveBottom(
p.y()); }
733 { moveRight(
p.x()); moveBottom(
p.y()); }
736 { xp =
p.x() -
w/2; yp =
p.y() -
h/2; }
773 return QRectF(xp + dx, yp + dy,
w,
h);
777 {
return QRectF(xp +
p.x(), yp +
p.y(),
w,
h); }
824 return QRectF(xp + xp1, yp + yp1,
w + xp2 - xp1,
h + yp2 - yp1);
871 const int nxp =
qRound(xp);
872 const int nyp =
qRound(yp);
873 const int nw =
qRound(
w + (xp - nxp) / 2);
874 const int nh =
qRound(
h + (yp - nyp) / 2);
875 return QRect(nxp, nyp, nw, nh);
881 QSizeF(lhs.width() +
rhs.left() +
rhs.right(), lhs.height() +
rhs.top() +
rhs.bottom()));
887 QSizeF(
rhs.width() + lhs.left() + lhs.right(),
rhs.height() + lhs.top() + lhs.bottom()));
893 QSizeF(lhs.width() -
rhs.left() -
rhs.right(), lhs.height() -
rhs.top() -
rhs.bottom()));
898 return QRectF(
QPointF(xp - margins.left(), yp - margins.top()),
899 QSizeF(
w + margins.left() + margins.right(),
h + margins.top() + margins.bottom()));
904 return QRectF(
QPointF(xp + margins.left(), yp + margins.top()),
905 QSizeF(
w - margins.left() - margins.right(),
h - margins.top() - margins.bottom()));
910 *
this = marginsAdded(margins);
916 *
this = marginsRemoved(margins);
920 #ifndef QT_NO_DEBUG_STREAM
const QByteArray operator+(const QByteArray &a1, const QByteArray &a2)
The QDataStream class provides serialization of binary data to a QIODevice.
operator>>(QDataStream &ds, qfloat16 &f)
operator<<(QDataStream &ds, qfloat16 f)
The QDebug class provides an output stream for debugging information.
template< typename Enum > size_t qHash(QFlags< Enum > flags, size_t seed=0) noexcept
template< typename... T > size_t qHashMulti(size_t seed, const T &...args)
The QMarginsF class defines the four margins of a rectangle.
The QMargins class defines the four margins of a rectangle.
QMargins operator-(const QMargins &m1, const QMargins &m2)
The QPointF class defines a point in the plane using floating point precision.
The QPoint class defines a point in the plane using integer precision.
The QRectF class defines a finite rectangle in the plane using floating point precision.
constexpr friend bool operator!=(const QRectF &r1, const QRectF &r2) noexcept
constexpr void moveCenter(const QPointF &p) noexcept
constexpr bool isEmpty() const noexcept
constexpr void moveTo(qreal x, qreal y) noexcept
constexpr qreal bottom() const noexcept
constexpr void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const
constexpr void setBottom(qreal pos) noexcept
constexpr void setRight(qreal pos) noexcept
constexpr void getRect(qreal *x, qreal *y, qreal *w, qreal *h) const
constexpr void setLeft(qreal pos) noexcept
constexpr qreal y() const noexcept
constexpr void setCoords(qreal x1, qreal y1, qreal x2, qreal y2) noexcept
constexpr qreal height() const noexcept
constexpr qreal width() const noexcept
constexpr qreal x() const noexcept
QRectF & operator&=(const QRectF &r) noexcept
constexpr QRectF marginsRemoved(const QMarginsF &margins) const noexcept
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
constexpr QRectF & operator+=(const QMarginsF &margins) noexcept
constexpr void setTopLeft(const QPointF &p) noexcept
constexpr void setTop(qreal pos) noexcept
bool contains(const QRectF &r) const noexcept
constexpr QRectF & operator-=(const QMarginsF &margins) noexcept
constexpr QPointF bottomLeft() const noexcept
constexpr QRectF() noexcept
constexpr void moveRight(qreal pos) noexcept
constexpr void setY(qreal pos) noexcept
constexpr void moveTopLeft(const QPointF &p) noexcept
constexpr QRectF marginsAdded(const QMarginsF &margins) const noexcept
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
constexpr void setBottomLeft(const QPointF &p) noexcept
constexpr void moveBottomLeft(const QPointF &p) noexcept
constexpr void setWidth(qreal w) noexcept
constexpr void moveBottom(qreal pos) noexcept
constexpr void setBottomRight(const QPointF &p) noexcept
constexpr void setSize(const QSizeF &s) noexcept
constexpr bool isNull() const noexcept
constexpr void moveBottomRight(const QPointF &p) noexcept
constexpr QPointF topLeft() const noexcept
constexpr QPointF center() const noexcept
constexpr bool isValid() const noexcept
constexpr void moveLeft(qreal pos) noexcept
constexpr QPointF bottomRight() const noexcept
constexpr QSizeF size() const noexcept
constexpr QRect toRect() const noexcept
constexpr void adjust(qreal x1, qreal y1, qreal x2, qreal y2) noexcept
constexpr void translate(qreal dx, qreal dy) noexcept
constexpr qreal top() const noexcept
constexpr void setHeight(qreal h) noexcept
constexpr void moveTop(qreal pos) noexcept
constexpr void setTopRight(const QPointF &p) noexcept
constexpr QPointF topRight() const noexcept
QRectF & operator|=(const QRectF &r) noexcept
constexpr QRectF transposed() const noexcept
QRectF intersected(const QRectF &other) const noexcept
constexpr void moveTopRight(const QPointF &p) noexcept
QRectF united(const QRectF &other) const noexcept
constexpr qreal right() const noexcept
constexpr void setRect(qreal x, qreal y, qreal w, qreal h) noexcept
The QRect class defines a rectangle in the plane using integer precision.
constexpr void moveBottomRight(const QPoint &p) noexcept
constexpr QRect & operator+=(const QMargins &margins) noexcept
constexpr QPoint bottomLeft() const noexcept
constexpr void setBottomLeft(const QPoint &p) noexcept
constexpr bool isEmpty() const noexcept
constexpr void getCoords(int *x1, int *y1, int *x2, int *y2) const
constexpr void moveTopLeft(const QPoint &p) noexcept
constexpr QRect marginsAdded(const QMargins &margins) const noexcept
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
constexpr void moveBottom(int pos) noexcept
constexpr void moveRight(int pos) noexcept
constexpr void moveCenter(const QPoint &p) noexcept
constexpr QRect & operator-=(const QMargins &margins) noexcept
constexpr void getRect(int *x, int *y, int *w, int *h) const
constexpr int height() const noexcept
constexpr bool isValid() const noexcept
constexpr bool isNull() const noexcept
QRect intersected(const QRect &other) const noexcept
constexpr int bottom() const noexcept
constexpr QRect marginsRemoved(const QMargins &margins) const noexcept
constexpr void setRight(int pos) noexcept
constexpr QPoint topLeft() const noexcept
constexpr void setSize(const QSize &s) noexcept
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
constexpr int top() const noexcept
constexpr QPoint topRight() const noexcept
constexpr void moveLeft(int pos) noexcept
constexpr void setBottom(int pos) noexcept
bool contains(const QRect &r, bool proper=false) const noexcept
static constexpr QRect span(const QPoint &p1, const QPoint &p2) noexcept
constexpr void setLeft(int pos) noexcept
constexpr int left() const noexcept
constexpr void setRect(int x, int y, int w, int h) noexcept
constexpr int x() const noexcept
QRect & operator&=(const QRect &r) noexcept
constexpr void setWidth(int w) noexcept
constexpr QRect() noexcept
constexpr void setX(int x) noexcept
constexpr void moveBottomLeft(const QPoint &p) noexcept
constexpr QSize size() const noexcept
constexpr void setTopLeft(const QPoint &p) noexcept
constexpr QRect transposed() const noexcept
constexpr void translate(int dx, int dy) noexcept
constexpr void setCoords(int x1, int y1, int x2, int y2) noexcept
constexpr QPoint bottomRight() const noexcept
constexpr int width() const noexcept
constexpr QRect translated(int dx, int dy) const noexcept
QRect united(const QRect &other) const noexcept
constexpr int y() const noexcept
constexpr void moveTopRight(const QPoint &p) noexcept
constexpr friend bool operator!=(const QRect &r1, const QRect &r2) noexcept
constexpr void setHeight(int h) noexcept
constexpr void moveTo(int x, int t) noexcept
constexpr void setBottomRight(const QPoint &p) noexcept
constexpr void moveTop(int pos) noexcept
QRect & operator|=(const QRect &r) noexcept
constexpr QPoint center() const noexcept
constexpr void setY(int y) noexcept
constexpr void setTopRight(const QPoint &p) noexcept
constexpr int right() const noexcept
constexpr void setTop(int pos) noexcept
The QSizeF class defines the size of a two-dimensional object using floating point precision.
The QSize class defines the size of a two-dimensional object using integer point precision.
auto it unsigned count const
QTextStream & center(QTextStream &stream)
#define QT_WARNING_DISABLE_FLOAT_COMPARE
int qRound(qfloat16 d) noexcept
QT_END_INCLUDE_NAMESPACE typedef double qreal
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat x1
GLdouble GLdouble GLdouble GLdouble top
GLfloat GLfloat GLfloat GLfloat h
GLfixed GLfixed GLfixed y2
GLenum GLenum GLsizei void GLsizei void void * span
GLint GLenum GLboolean normalized
Q_DECLARE_TYPEINFO(QRect, Q_RELOCATABLE_TYPE)
constexpr size_t qHash(const QRect &r, size_t seed=0) noexcept