Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QRect QRect::normalized (  )  const

Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.

If width() < 0 the function swaps the left and right corners, and it swaps the top and bottom corners if height() < 0.

See also:
isValid(), isEmpty()

Definition at line 278 of file qrect.cpp.

References height(), isNull(), width(), x1, x2, y1, and y2.

Referenced by Q3Painter::adjustedRectangle(), contains(), Q3IconView::doAutoScroll(), QPlastiqueStyle::drawControl(), QPainter::drawEllipse(), QRasterPaintEngine::drawRects(), QRegion::intersects(), intersects(), QListView::mouseMoveEvent(), operator &(), operator|(), QHeaderView::resizeSection(), QTreeView::timerEvent(), and QTableView::timerEvent().

{
    if (isNull() || width() == 0 || height() == 0)
        return *this;
    QRect r;
    if (x2 < x1) {                                // swap bad x values
        r.x1 = x2;
        r.x2 = x1;
    } else {
        r.x1 = x1;
        r.x2 = x2;
    }
    if (y2 < y1) {                                // swap bad y values
        r.y1 = y2;
        r.y2 = y1;
    } else {
        r.y1 = y1;
        r.y2 = y2;
    }
    return r;
}


Generated by  Doxygen 1.6.0   Back to index