Yes with anchors.fill:parent, Pressed/Released works only if the mouse is exactly on the line, while hover seems to use the bounding rect of the polyline...

But anyway with containmentMask: polyline, all is OK and hover occurs only exactly on the line.

The only thing one could hope for is a possibility to make the mouse area a bit thicker than the line width, because with thin lines it is difficult to be exactly on it.

Philippe.

Le 08-03-2019 11:07, Paolo Angelelli a écrit :
Pressed/released should work as expected, shouldn't it?

Hovered is a different story though.

On Thu, 07 Mar 2019 18:32:35 +0100
maitai <mai...@virtual-winds.org> wrote:

Hi,

I need to trigger various actions whenever a MapPolyLine is hovered or
pressed, such as displaying a tooltip, a menu, etc.

I have put a MouseArea on it with anchors.fills: parent, but the problem is that the mouse area does not represent the line, but the polygon made by the line. For instance if you have a L shape, entered event and so on is triggered when you enter the bounding rectangle of the line, not when
you hover over the line itself.

On a QGraphicsScene we had the shape() protected method for that kinds
of case, for instance with a QPainterPathStroker to give some thickness
to the line's "mousearea".

I will probably end with a custom property that will carry the pixel
distance between the line segments and the mouse coordinates, but this
is going to be heavy to compute (I have potentially hundreds of
complicated lines on the map).

Is there a better way or even better a standard way to do that?

Thanks
Philippe Lelong
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

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

Reply via email to