[Development] QRect::contains and undocumented(?) edge
Allan Sandfeld Jensen
kde at carewolf.com
Thu Apr 21 21:28:46 CEST 2022
On Donnerstag, 21. April 2022 16:09:37 CEST Thiago Macieira wrote:
> On Thursday, 21 April 2022 06:22:57 PDT Tomi Pannila wrote:
> > Is there a possibility to add a picture to Qt documentation where you
> > have a rectangle grid and shade the
> > edge cells with some color to identify them as edges? If I'm the only
> > one confused of the term edge, not edge cell, in integer
> > rectangle, then this is not needed.
>
> You're not. The problem is that, as Aavit described, the class was designed
> as an intuitive chess board or pixel board, not as a mathematical
> construct.
>
> A QRect of (0,0) to (1,1) is a 2x2 square. So a square of a single pixel is
> (0,0) to (0,0). But then how do you make an empty QRect, that is, a (0,0)
> +0+0?
>
(0,0) to (-1,-1)
When the "bottom-right" corner is above and to the left of the "top-left"
corner, the borders excluded instead of included. Weird but it works, and I
made it consistent in Qt6 (I believe it was 6.0, could have been before).
So (1,1)->(2,2) is the same as (3,3)->(0,0)
But yes. It is weird and ugly logic, to keep this old nonsense going.
'Allan
More information about the Development
mailing list