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

📄 qrect.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    Moves the rectangle, leaving the top-left corner at the given \a    position. The rectangle's size is unchanged.    \sa setTopLeft(), moveTop(), moveLeft()*//*!    \fn void QRectF::moveBottomRight(const QPointF &position)    Moves the rectangle, leaving the bottom-right corner at the given    \a position. The rectangle's size is unchanged.    \sa setBottomRight(), moveBottom(), moveRight()*//*!    \fn void QRectF::moveTopRight(const QPointF &position)    Moves the rectangle, leaving the top-right corner at the given    \a position. The rectangle's size is unchanged.    \sa setTopRight(), moveTop(), moveRight()*//*!    \fn void QRectF::moveBottomLeft(const QPointF &position)    Moves the rectangle, leaving the bottom-left corner at the given    \a position. The rectangle's size is unchanged.    \sa setBottomLeft(), moveBottom(), moveLeft()*//*!    \fn void QRectF::moveTo(qreal x, qreal y)    Moves the rectangle, leaving the top-left corner at the given    position (\a x, \a y). The rectangle's size is unchanged.    \sa translate(), moveTopLeft()*//*!    \fn void QRectF::moveTo(const QPointF &position)    \overload    Moves the rectangle, leaving the top-left corner at the given \a    position.*//*!    \fn void QRectF::translate(qreal dx, qreal dy)    Moves the rectangle \a dx along the x-axis and \a dy along the y-axis,    relative to the current position. Positive values move the rectangle to the    right and downwards.    \sa moveTopLeft(),  moveTo(),  translated()*//*!    \fn void QRectF::translate(const QPointF &offset)    \overload    Moves the rectangle \a{offset}.\l{QPointF::x()}{x()} along the x    axis and \a{offset}.\l{QPointF::y()}{y()} along the y axis,    relative to the current position.*//*!    \fn QRectF QRectF::translated(qreal dx, qreal dy) const    Returns a copy of the rectangle that is translated \a dx along the    x axis and \a dy along the y axis, relative to the current    position. Positive values move the rectangle to the right and    down.    \sa translate()*//*!    \fn QRectF QRectF::translated(const QPointF &offset) const    \overload    Returns a copy of the rectangle that is translated    \a{offset}.\l{QPointF::x()}{x()} along the x axis and    \a{offset}.\l{QPointF::y()}{y()} along the y axis, relative to the    current position.*//*!    \fn void QRectF::setRect(qreal x, qreal y, qreal width, qreal height)    Sets the coordinates of the rectangle's top-left corner to (\a x,    \a y), and its size to the given \a width and \a height.    \sa getRect(), setCoords()*//*!    \fn void QRectF::setCoords(qreal x1, qreal y1, qreal x2, qreal y2)    Sets the coordinates of the rectangle's top-left corner to (\a x1,    \a y1), and the coordinates of its bottom-right corner to (\a x2,    \a y2).    \sa getCoords() setRect()*//*!    \fn QRectF QRectF::adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const    Returns a new rectangle with \a dx1, \a dy1, \a dx2 and \a dy2    added respectively to the existing coordinates of this rectangle.    \sa adjust()*//*! \fn void QRectF::adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2)    Adds \a dx1, \a dy1, \a dx2 and \a dy2 respectively to the    existing coordinates of the rectangle.    \sa adjusted(), setRect()*//*!    \fn QSizeF QRectF::size() const    Returns the size of the rectangle.    \sa setSize(), width(), height()*//*!    \fn qreal QRectF::width() const    Returns the width of the rectangle.    \sa setWidth(), height(), size()*//*!    \fn qreal QRectF::height() const    Returns the height of the rectangle.    \sa setHeight(), width(), size()*//*!    \fn void QRectF::setWidth(qreal width)    Sets the width of the rectangle to the given \a width. The right    edge is changed, but not the left one.    \sa width(), setSize()*//*!    \fn void QRectF::setHeight(qreal height)    Sets the height of the rectangle to the given \a height. The bottom    edge is changed, but not the top one.    \sa height(), setSize()*//*!    \fn void QRectF::setSize(const QSizeF &size)    Sets the size of the rectangle to the given \a size. The top-left    corner is not moved.    \sa size(), setWidth(), setHeight()*//*!    \fn bool QRectF::contains(const QPointF &point) const    Returns true if the given \a point is inside or on the edge of the    rectangle; otherwise returns false.    \sa intersects()*/bool QRectF::contains(const QPointF &p) const{    if (isNull())        return false;    QRectF r = normalized();    return p.x() >= r.xp && p.x() <= r.xp + r.w &&           p.y() >= r.yp && p.y() <= r.yp + r.h;}/*!    \fn bool QRectF::contains(qreal x, qreal y) const    \overload    Returns true if the point (\a x, \a y) is inside or on the edge of    the rectangle; otherwise returns false.*//*!    \fn bool QRectF::contains(const QRectF &rectangle) const    \overload    Returns true if the given \a rectangle is inside this rectangle;    otherwise returns false.*/bool QRectF::contains(const QRectF &r) const{    if (isNull() || r.isNull())        return false;    QRectF r1 = normalized();    QRectF r2 = r.normalized();    return r2.xp >= r1.xp && r2.xp + r2.w <= r1.xp + r1.w        && r2.yp >= r1.yp && r2.yp + r2.h <= r1.yp + r1.h;}/*!    \fn qreal QRectF::left() const    Returns the x-coordinate of the rectangle's left edge. Equivalent    to x().    \sa setLeft(), topLeft(), bottomLeft()*//*!    \fn qreal QRectF::top() const    Returns the y-coordinate of the rectangle's top edge. Equivalent    to y().    \sa setTop(), topLeft(), topRight()*//*!    \fn qreal QRectF::right() const    Returns the x-coordinate of the rectangle's right edge.    \sa setRight(), topRight(), bottomRight()*//*!    \fn qreal QRectF::bottom() const    Returns the y-coordinate of the rectangle's bottom edge.    \sa setBottom(), bottomLeft(), bottomRight()*//*!    \fn QPointF QRectF::topLeft() const    Returns the position of the rectangle's top-left corner.    \sa setTopLeft(), top(), left()*//*!    \fn QPointF QRectF::bottomRight() const    Returns the position of the rectangle's  bottom-right corner.    \sa setBottomRight(), bottom(), right()*//*!    \fn QPointF QRectF::topRight() const    Returns the position of the rectangle's top-right corner.    \sa setTopRight(), top(), right()*//*!    \fn QPointF QRectF::bottomLeft() const    Returns the position of the rectangle's  bottom-left corner.    \sa setBottomLeft(),  bottom(), left()*//*!    \fn QRectF& QRectF::operator|=(const QRectF &rectangle)    Unites this rectangle with the given \a rectangle.    \sa united(), operator|()*//*!    \fn QRectF& QRectF::operator&=(const QRectF &rectangle)    Intersects this rectangle with the given \a rectangle.    \sa intersected(), operator|=()*//*!    \fn QRectF QRectF::operator|(const QRectF &rectangle) const    Returns the bounding rectangle of this rectangle and the given \a rectangle.    \sa united(), operator|=()*/QRectF QRectF::operator|(const QRectF &r) const{    if (isNull())        return r;    if (r.isNull())        return *this;    QRectF r1 = normalized();    QRectF r2 = r.normalized();    QRectF tmp;    tmp.xp = qMin(r1.xp, r2.xp);    tmp.yp = qMin(r1.yp, r2.yp);    tmp.w = qMax(r1.xp + r1.w, r2.xp + r2.w) - tmp.xp;    tmp.h = qMax(r1.yp + r1.h, r2.yp + r2.h) - tmp.yp;    return tmp;}/*!    \fn QRectF QRectF::unite(const QRectF &rectangle) const    \obsolete    Use united(\a rectangle) instead.*//*!    \fn QRectF QRectF::united(const QRectF &rectangle) const    \since 4.2    Returns the bounding rectangle of this rectangle and the given \a    rectangle.    \image qrect-unite.png    \sa intersected()*//*!    \fn QRectF QRectF::operator &(const QRectF &rectangle) const    Returns the intersection of this rectangle and the given \a    rectangle. Returns an empty rectangle if there is no intersection.    \sa operator&=(), intersected()*/QRectF QRectF::operator&(const QRectF &r) const{    if (isNull() || r.isNull())        return QRectF();    QRectF r1 = normalized();    QRectF r2 = r.normalized();    QRectF tmp;    tmp.xp = qMax(r1.xp, r2.xp);    tmp.yp = qMax(r1.yp, r2.yp);    tmp.w = qMin(r1.xp + r1.w, r2.xp + r2.w) - tmp.xp;    tmp.h = qMin(r1.yp + r1.h, r2.yp + r2.h) - tmp.yp;    return tmp.isEmpty() ? QRectF() : tmp;}/*!    \fn QRectF QRectF::intersect(const QRectF &rectangle) const    \obsolete    Use intersected(\a rectangle) instead.*//*!    \fn QRectF QRectF::intersected(const QRectF &rectangle) const    \since 4.2    Returns the intersection of this rectangle and the given \a    rectangle. Note that \c {r.intersected(s)} is equivalent to \c    {r & s}.    \image qrect-intersect.png    \sa intersects(), united(), operator&=()*//*!    \fn bool QRectF::intersects(const QRectF &rectangle) const    Returns true if this rectangle intersects with the given \a    rectangle (i.e. there is a non-empty area of overlap between    them), otherwise returns false.    The intersection rectangle can be retrieved using the intersected()    function.    \sa contains()*/bool QRectF::intersects(const QRectF &r) const{    if (isNull() || r.isNull())        return false;    QRectF r1 = normalized();    QRectF r2 = r.normalized();    return qMax(r1.xp, r2.xp) < qMin(r1.xp + r1.w, r2.xp + r2.w)        && qMax(r1.yp, r2.yp) < qMin(r1.yp + r1.h, r2.yp + r2.h);}/*!    \fn QRect QRectF::toRect() const    Returns a QRect based on the values of this rectangle.  Note that the    coordinates in the returned rectangle are rounded to the nearest integer.    \sa QRectF(), toAlignedRect()*//*!    \fn QRect QRectF::toAlignedRect() const    \since 4.3    Returns a QRect based on the values of this rectangle that is the    smallest possible integer rectangle that completely contains this    rectangle.    \sa toRect()*/QRect QRectF::toAlignedRect() const{    int xmin = int(floor(x()));    int xmax = int(ceil(x() + width()));    int ymin = int(floor(y()));    int ymax = int(ceil(y() + height()));    return QRect(xmin, ymin, xmax - xmin, ymax - ymin);}/*!    \fn void QRectF::moveCenter(const QPointF &position)    Moves the rectangle, leaving the center point at the given \a    position. The rectangle's size is unchanged.    \sa center()*//*!    \fn bool operator==(const QRectF &r1, const QRectF &r2)    \relates QRectF    Returns true if the rectangles \a r1 and \a r2 are equal,    otherwise returns false.*//*!    \fn bool operator!=(const QRectF &r1, const QRectF &r2)    \relates QRectF    Returns true if the rectangles \a r1 and \a r2 are different, otherwise    returns false.*//*****************************************************************************  QRectF stream functions *****************************************************************************/#ifndef QT_NO_DATASTREAM/*!    \fn QDataStream &operator<<(QDataStream &stream, const QRectF &rectangle)    \relates QRectF    Writes the \a rectangle to the \a stream, and returns a reference to the    stream.    \sa \link datastreamformat.html Format of the QDataStream operators \endlink*/QDataStream &operator<<(QDataStream &s, const QRectF &r){    s << double(r.x()) << double(r.y()) << double(r.width()) << double(r.height());    return s;}/*!    \fn QDataStream &operator>>(QDataStream &stream, QRectF &rectangle)    \relates QRectF    Reads a \a rectangle from the \a stream, and returns a reference to the    stream.    \sa \link datastreamformat.html Format of the QDataStream operators \endlink*/QDataStream &operator>>(QDataStream &s, QRectF &r){    double x, y, w, h;    s >> x;    s >> y;    s >> w;    s >> h;    r.setRect(qreal(x), qreal(y), qreal(w), qreal(h));    return s;}#endif // QT_NO_DATASTREAM#ifndef QT_NO_DEBUG_STREAMQDebug operator<<(QDebug dbg, const QRectF &r) {    dbg.nospace() << "QRectF(" << r.x() << ',' << r.y() << ' '                  << r.width() << 'x' << r.height() << ')';    return dbg.space();}#endif

⌨️ 快捷键说明

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