Question

is it possible in qt to find the intersection point of two QLineF. i have draw one line cross to another and i want to find the intersection point of the two lines. im drawing inside a qgraphicsitem paint event .

Was it helpful?

Solution

Yes, it is possible.

IntersectType QLineF::intersect(const QLineF & line, QPointF * intersectionPoint) const

Returns a value indicating whether or not this line intersects with the given line.

The actual intersection point is extracted to intersectionPoint (if the pointer is valid). If the lines are parallel, the intersection point is undefined.

So, you will get the intersection point in the intersectionPoint output parameter. Therefore, you would be writing something like this:

// Get the two lines
myLineF1.interect(myLineF2, myIntersectionPoint);
// Do something with myIntersectionPoint
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top