> On 8 Mar 2019, at 11:29, maitai <mai...@virtual-winds.org> wrote:
> 
> 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.

You could maybe use an invisible polyline (zero opacity?) just to define the 
mask?  But it will waste memory of course, if you need to have a lot of 
selectable polylines.  The Event Handlers (like HoverHandler and TapHandler) 
have a margin property, but so far we have not made it apply to the mask, but 
rather override the mask (it will hit-test the rectangular bounds with a margin 
applied, i.e. it will test a larger rectangle if the margin is positive).  It 
might be nice to have it check the mask with a margin applied, but that might 
be expensive, and would anyway involve creating an extra QPainterPath to 
represent the “expanded hull” of the shape (or maybe just the stroke of the 
shape if that’s what you want).  For now we are looping and checking contains() 
on every QPainterPath from which the Shape is composed… which has its own 
expense (memory vs. CPU trade-off).  ContainsMode could have a new value 
HullContains or something like that.  See the implementation in 
QQuickShape::contains():

bool QQuickShape::contains(const QPointF &point) const
{
    Q_D(const QQuickShape);
    switch (d->containsMode) {
    case BoundingRectContains:
        return QQuickItem::contains(point);
    case FillContains:
        for (QQuickShapePath *path : d->sp) {
            if (path->path().contains(point))
                return true;
        }
    }
    return false;
}

That’s just an idea… I haven’t tried to implement it.

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

Reply via email to