⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qrect.h

📁 奇趣公司比较新的qt/emd版本
💻 H
📖 第 1 页 / 共 2 页
字号:
inline void QRect::adjust(int dx1, int dy1, int dx2, int dy2){    x1 += dx1;    y1 += dy1;    x2 += dx2;    y2 += dy2;}inline void QRect::setWidth(int w){ x2 = (x1 + w - 1); }inline void QRect::setHeight(int h){ y2 = (y1 + h - 1); }inline void QRect::setSize(const QSize &s){    x2 = (s.width()  + x1 - 1);    y2 = (s.height() + y1 - 1);}inline bool QRect::contains(int ax, int ay, bool aproper) const{    return contains(QPoint(ax, ay), aproper);}inline bool QRect::contains(int ax, int ay) const{    return contains(QPoint(ax, ay), false);}inline QRect& QRect::operator|=(const QRect &r){    *this = *this | r;    return *this;}inline QRect& QRect::operator&=(const QRect &r){    *this = *this & r;    return *this;}inline QRect QRect::intersect(const QRect &r) const{    return *this & r;}inline QRect QRect::intersected(const QRect &other) const{    return intersect(other);}inline QRect QRect::unite(const QRect &r) const{    return *this | r;}inline QRect QRect::united(const QRect &r) const{     return unite(r);}inline bool operator==(const QRect &r1, const QRect &r2){    return r1.x1==r2.x1 && r1.x2==r2.x2 && r1.y1==r2.y1 && r1.y2==r2.y2;}inline bool operator!=(const QRect &r1, const QRect &r2){    return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2;}#ifndef QT_NO_DEBUG_STREAMQ_CORE_EXPORT QDebug operator<<(QDebug, const QRect &);#endifclass Q_CORE_EXPORT QRectF{public:    QRectF() { xp = yp = 0.; w = h = 0.; }    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;    inline qreal left() const { return xp; }    inline qreal top() const { return yp; }    inline qreal right() const { return xp + w; }    inline qreal bottom() const { return yp + h; }    inline qreal x() const;    inline qreal y() const;    inline void setLeft(qreal pos);    inline void setTop(qreal pos);    inline void setRight(qreal pos);    inline void setBottom(qreal pos);    inline void setX(qreal pos) { setLeft(pos); }    inline void setY(qreal pos) { setTop(pos); }    inline QPointF topLeft() const { return QPointF(xp, yp); }    inline QPointF bottomRight() const { return QPointF(xp+w, yp+h); }    inline QPointF topRight() const { return QPointF(xp+w, yp); }    inline QPointF bottomLeft() const { return QPointF(xp, yp+h); }    inline 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;    inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2);    inline 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;    QRectF& operator|=(const QRectF &r);    QRectF& operator&=(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;  // ### Qt 5: make QT4_SUPPORT    QRectF united(const QRectF &other) const;    QRectF intersect(const QRectF &r) const;  // ### Qt 5: make QT4_SUPPORT    QRectF intersected(const QRectF &other) const;    bool intersects(const QRectF &r) const;    friend Q_CORE_EXPORT_INLINE bool operator==(const QRectF &, const QRectF &);    friend Q_CORE_EXPORT_INLINE bool operator!=(const QRectF &, const QRectF &);    QRect toRect() const;    QRect toAlignedRect() const;private:    qreal xp;    qreal yp;    qreal w;    qreal h;};Q_DECLARE_TYPEINFO(QRectF, Q_MOVABLE_TYPE);Q_CORE_EXPORT_INLINE bool operator==(const QRectF &, const QRectF &);Q_CORE_EXPORT_INLINE bool operator!=(const QRectF &, const QRectF &);/*****************************************************************************  QRectF stream functions *****************************************************************************/#ifndef QT_NO_DATASTREAMQ_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QRectF &);Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QRectF &);#endif/*****************************************************************************  QRectF inline member functions *****************************************************************************/inline QRectF::QRectF(qreal aleft, qreal atop, qreal awidth, qreal aheight)    : xp(aleft), yp(atop), w(awidth), h(aheight){}inline QRectF::QRectF(const QPointF &atopLeft, const QSizeF &asize){    xp = atopLeft.x();    yp = atopLeft.y();    w = asize.width();    h = asize.height();}inline QRectF::QRectF(const QPointF &atopLeft, const QPointF &abottomRight){    xp = atopLeft.x();    yp = atopLeft.y();    w = abottomRight.x() - xp;    h = abottomRight.y() - yp;}inline QRectF::QRectF(const QRect &r)    : xp(r.x()), yp(r.y()), w(r.width()), h(r.height()){}inline bool QRectF::isNull() const{ return qIsNull(w) && qIsNull(h); }inline bool QRectF::isEmpty() const{ return w <= 0. || h <= 0.; }inline bool QRectF::isValid() const{ return w > 0. && h > 0.; }inline qreal QRectF::x() const{ return xp; }inline qreal QRectF::y() const{ return yp; }inline void QRectF::setLeft(qreal pos) { qreal diff = pos - xp; xp += diff; w -= diff; }inline void QRectF::setRight(qreal pos) { w = pos - xp; }inline void QRectF::setTop(qreal pos) { qreal diff = pos - yp; yp += diff; h -= diff; }inline void QRectF::setBottom(qreal pos) { h = pos - yp; }inline void QRectF::setTopLeft(const QPointF &p) { setLeft(p.x()); setTop(p.y()); }inline void QRectF::setTopRight(const QPointF &p) { setRight(p.x()); setTop(p.y()); }inline void QRectF::setBottomLeft(const QPointF &p) { setLeft(p.x()); setBottom(p.y()); }inline void QRectF::setBottomRight(const QPointF &p) { setRight(p.x()); setBottom(p.y()); }inline QPointF QRectF::center() const{ return QPointF(xp + w/2, yp + h/2); }inline void QRectF::moveLeft(qreal pos) { xp = pos; }inline void QRectF::moveTop(qreal pos) { yp = pos; }inline void QRectF::moveRight(qreal pos) { xp = pos - w; }inline void QRectF::moveBottom(qreal pos) { yp = pos - h; }inline void QRectF::moveTopLeft(const QPointF &p) { moveLeft(p.x()); moveTop(p.y()); }inline void QRectF::moveTopRight(const QPointF &p) { moveRight(p.x()); moveTop(p.y()); }inline void QRectF::moveBottomLeft(const QPointF &p) { moveLeft(p.x()); moveBottom(p.y()); }inline void QRectF::moveBottomRight(const QPointF &p) { moveRight(p.x()); moveBottom(p.y()); }inline void QRectF::moveCenter(const QPointF &p) { xp = p.x() - w/2; yp = p.y() - h/2; }inline qreal QRectF::width() const{ return w; }inline qreal QRectF::height() const{ return h; }inline QSizeF QRectF::size() const{ return QSizeF(w, h); }inline void QRectF::translate(qreal dx, qreal dy){    xp += dx;    yp += dy;}inline void QRectF::translate(const QPointF &p){    xp += p.x();    yp += p.y();}inline void QRectF::moveTo(qreal ax, qreal ay){    xp = ax;    yp = ay;}inline void QRectF::moveTo(const QPointF &p){    xp = p.x();    yp = p.y();}inline QRectF QRectF::translated(qreal dx, qreal dy) const{ return QRectF(xp + dx, yp + dy, w, h); }inline QRectF QRectF::translated(const QPointF &p) const{ return QRectF(xp + p.x(), yp + p.y(), w, h); }inline void QRectF::getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) const{    *ax = this->xp;    *ay = this->yp;    *aaw = this->w;    *aah = this->h;}inline void QRectF::setRect(qreal ax, qreal ay, qreal aaw, qreal aah){    this->xp = ax;    this->yp = ay;    this->w = aaw;    this->h = aah;}inline void QRectF::getCoords(qreal *xp1, qreal *yp1, qreal *xp2, qreal *yp2) const{    *xp1 = xp;    *yp1 = yp;    *xp2 = xp + w;    *yp2 = yp + h;}inline void QRectF::setCoords(qreal xp1, qreal yp1, qreal xp2, qreal yp2){    xp = xp1;    yp = yp1;    w = xp2 - xp1;    h = yp2 - yp1;}inline void QRectF::adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2){ xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; }inline QRectF QRectF::adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const{ return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1); }inline void QRectF::setWidth(qreal aw){ this->w = aw; }inline void QRectF::setHeight(qreal ah){ this->h = ah; }inline void QRectF::setSize(const QSizeF &s){    w = s.width();    h = s.height();}inline bool QRectF::contains(qreal ax, qreal ay) const{    return contains(QPointF(ax, ay));}inline QRectF& QRectF::operator|=(const QRectF &r){    *this = *this | r;    return *this;}inline QRectF& QRectF::operator&=(const QRectF &r){    *this = *this & r;    return *this;}inline QRectF QRectF::intersect(const QRectF &r) const{    return *this & r;}inline QRectF QRectF::intersected(const QRectF &r) const{    return intersect(r);}inline QRectF QRectF::unite(const QRectF &r) const{    return *this | r;}inline QRectF QRectF::united(const QRectF &r) const{    return unite(r);}inline bool operator==(const QRectF &r1, const QRectF &r2){    return qFuzzyCompare(r1.xp, r2.xp) && qFuzzyCompare(r1.yp, r2.yp)           && qFuzzyCompare(r1.w, r2.w) && qFuzzyCompare(r1.h, r2.h);}inline bool operator!=(const QRectF &r1, const QRectF &r2){    return !qFuzzyCompare(r1.xp, r2.xp) || !qFuzzyCompare(r1.yp, r2.yp)           || !qFuzzyCompare(r1.w, r2.w) || !qFuzzyCompare(r1.h, r2.h);}inline QRect QRectF::toRect() const{    return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h));}#ifndef QT_NO_DEBUG_STREAMQ_CORE_EXPORT QDebug operator<<(QDebug, const QRectF &);#endifQT_END_HEADER#endif // QRECT_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -