Pergunta

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 .

Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top