0

I have a QChart with a number of QLineSeries and QScatterSeries on it. I would like to be able to use the mouse to click-drag a line or a box shape and to detect all series which intersect that box.

I currently have a QGraphicsItem being drawn when I click-drag and I am now trying to detect which series are in that box (note there may be no actual data points in the box, but there may be a section of a line drawn interpolated between 2 data series points).

I don't want to manually detect the intersection by calculating the interpolation points and testing if they are inside my selection box (I'm pretty sure Qt can do this for me), so I'm trying to use the QGraphicsItem::shape() and QGraphicsItem::collidesWith() routines to detect collision. However, I can't seem to get the QGraphicsItem representation of a QLineSeries - is this possible at all?

Would it be better to try and use a QPainterPath? How would I use that in this case?

I also tried to use the hovered(const QPointF &, bool) signal of the data series, so I could record which series were hovered over when the selection box was dragged out, but this signal doesn't fire when the left mouse button is down for some reason. :/

4

1 に答える 1