Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

QRegion will be iterable in Qt 5.8

- seamless integration with C++11 range-for


void inspect(const QRegion &region) {
    for (const QRect &rect : region.rects())
        inspect(rect);
}

void inspect(const QRegion &region) {
    if (region.rectCount() == 1) {
        inspect(region.boundingRect());
    } else {
        const auto rects = region.rects(); // make const to avoid a detach in the implicit begin() call below:
        for (const QRect &rect : rects)
            inspect(rect);
    }
}

    const QRect *begin() const Q_DECL_NOTHROW
    { return numRects == 1 ? &extents : rects.data(); } // avoid vectorize()

    const QRect *end() const Q_DECL_NOTHROW
    { return begin() + numRects; }

void inspect(const QRegion &region)
    noexcept(noexcept(inspect(std::declval<QRect&>()))) // noexcept whenever inspect(QRect) is
{
    for (const QRect &rect : region)
        inspect(rect);
}