QPolygonF has methods to union, intersect, and subtract with other QPolygonFs but I need to perform an intersection test with a QLineF. This appears to be missing from the API.
I suppose I could do something like this:
if (polygon .containsPoint (line .p1 ()) != polygon .containsPoint (line .p2 ())
return true;
QPointF a = polygon .back ();
foreach (QPointF b, polygon)
{
if (QLineF :: BoundedIntersection == line .intersect (QPointF (a, b))
return true;
a = b;
}
return false;
There are probably some numerical or edge-case surprises lurking in the above, so I’d rather not.
Is there a provided method somewhere in the Qt API that I can’t see?
Unfortunately, the answer is “no”.