質問

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