Given a QPoint and a QPainterPath.
How do I find the distance from the QPoint to the
closest point along the QPainterPath.


Perhaps. But you should consider that QPainterPath is, as the name
suggests, primarily for painting, and not meant for solving generic
geometric problems. So I'm not sure how a feature request for this
would be received by the Qt devs. Point projection is one problem, but
there are many others, and they are surely not all within the scope of
QPainterPath.


I think Qt opened the door for geometric consideration when they
invented the scene, gave items mouse-event-handlers and provided
intersection based item queries.   :-)

If I were you, I would instead try to find a library that can
calculate the minimum point-to-bezier distance, or if you feel up for
it, implement it yourself. The line case is trivial.

I do not take the addition of a new library and the subsequent
dependency lightly.

In this case, I will just brute force with pointAtPercent.

Thanks.

Bill


Elvis


I could then use QGraphicsScene::items() to find the
intersecting set of a bounding rectangle around the
mouse click and then nail it down with distance to
each object in that set.


Elvis


Thanks.

Bill

---------
All of the above to find the shape closest to a mouse click.
Note that methods are provided to find the set of objects
which intersect a rectangle centered on the point, but which one
is really the closest?
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest



_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to