[Interest] strange behaviour of QRegion::contains(QRect)
Manner Róbert
rmanni at gmail.com
Tue Aug 28 16:05:56 CEST 2018
Hi,
Works, as it is documented, but I think QRegion::contains(QRect) is a
bit confusing. Example:
QRect bigRect(0, 0, 10, 10);
QRegion smallRegion;
smallRegion += QRect(0, 0, 1, 1);
smallRegion.contains(bigRect.bottomRight()) --> returns false of
course, bigRect is bigger
smallRegion.contains(bigRect) --> returns true ???
The reason is, according to the documentation, it is true if the region
"overlaps" the rectangle. So in this case contains does not mean
containment, but intersection.
For this use case, QRegion already has an intersects() function which
does what it says. I think the contains function should be deprecated
and removed, or, it should behave according to its name (eg return
this->substracted(rect).isEmpty()).
Robert
More information about the Interest
mailing list