[Development] QRect::contains and undocumented(?) edge

Eirik Aavitsland eirik.aavitsland at qt.io
Thu Apr 21 10:39:01 CEST 2022

On 4/20/22 17:50, Tomi Pannila wrote:
> Hi Lars and Eirik,
> thank you for the explanations. I guess Eirik kind of guessed right that 
> I view QRect from $\mathbb{R}^2$ point of view.
> I'm a mathematician and this is the most natural point of view for me. 
> For me, rectangles have edges=boundary which are measure zero.

But QRect is not a mathematical (cartesian) rectangle, instead it 
describes a chess board. If one asks anybody which squares are on the 
edge of the board, they will correctly point out row 1 and 8, and column 
A and H. That is exactly the meaning of "edge" in the doc of 
QRect::contains() - it is the everyday, intuitive and obvious meaning. 
So I don't see the problem with the current api, except for the 
anonymosity of the bool parameter, as Lars pointed out. Also, there is 
an overload of QRect::contains() without the bool parameter, so no edge 
to worry about at all, so I don't really understand what the problem is.
(And if one wants to do operate on rects with borders, one can simply 
use QMargins together with QRect, e.g. QRect::marginsAdded()).

- Eirik Aa.

More information about the Development mailing list