Solved Is there is existing function to find midpoint of QLineF
-
I went through http://doc.qt.io/qt-4.8/qlinef-members.html and its list of functions . I could not find a readymade function that finds the midpoint of the QLineF .Is the any existing function to find the same . If point
How about
QPointF mid = QPointF((QLineF.p1().x()+ QLineF.p2().x())/2) ,(QLineF.p1().y()+ QLineF.p2().y())/2 )
Please let me know
-
Nothing exist in qt. you can apply mathematical formula and get it.
-
I think you want the center() function?
-
I cannot find anyone
-
Ah sorry, I see you are using an older version than me (Qt 5.8). It probably does not exist in Qt 4.8. So it is the manual method for you :-).
from the QT 5.8 docs. it does this 0.5 * p1() + 0.5 * p2() which is the equivalent of yours. -
I haven't test it but you can try something like this:
QRectF(line.P1(),line.p2()).center()