문제

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 .

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top