QLineSeries::hovered
-
I'm getting what I believe is "unexpected" results from handling this signal.
I have this slot for handling the hovered signal:
void ChartTab::scoreHovered(const QPointF& point, bool state) { if (state) { const QPoint globalMouseLocation(QCursor::pos()); QLocale locale; QToolTip::showText(globalMouseLocation, locale.toString(point.y(), 'f', 2), this); } }When I position it over a point in the lineSeries it displays the tooltip, but it also does so when I position it over the line that connects the points in the series (and it shows that value at that location on the line).
I would have expected it to only display the tooltip when over a point in the series.
-
I'm getting what I believe is "unexpected" results from handling this signal.
I have this slot for handling the hovered signal:
void ChartTab::scoreHovered(const QPointF& point, bool state) { if (state) { const QPoint globalMouseLocation(QCursor::pos()); QLocale locale; QToolTip::showText(globalMouseLocation, locale.toString(point.y(), 'f', 2), this); } }When I position it over a point in the lineSeries it displays the tooltip, but it also does so when I position it over the line that connects the points in the series (and it shows that value at that location on the line).
I would have expected it to only display the tooltip when over a point in the series.
-
I still think it should not behave as it does. Could someone who knows please comment.
Thanks
@Perdrix
What type isChartTab? Are we to assume from "lineSeries" that you have a QtChart here? "hovered signal" of what class?If we should guess you are asking about signal void QXYSeries::hovered(const QPointF &point, bool state), which says:
This signal is emitted when a mouse is hovered over the point point in the chart.
then we may have a misunderstanding about the word "point" here? You take that to mean an actual point which you have added to the chart, but per other Qt documentation "the point point" may only mean " a point specified by
pointanywhere on the chart", in the sense of a "coordinate somewhere on the chart" rather than "an actual plotted point".If that is so and you want the hover only on plotted points, you may have to compare the mouse coordinate against the points in the points list, looking for it being "close" to one of those?
-
@Perdrix
What type isChartTab? Are we to assume from "lineSeries" that you have a QtChart here? "hovered signal" of what class?If we should guess you are asking about signal void QXYSeries::hovered(const QPointF &point, bool state), which says:
This signal is emitted when a mouse is hovered over the point point in the chart.
then we may have a misunderstanding about the word "point" here? You take that to mean an actual point which you have added to the chart, but per other Qt documentation "the point point" may only mean " a point specified by
pointanywhere on the chart", in the sense of a "coordinate somewhere on the chart" rather than "an actual plotted point".If that is so and you want the hover only on plotted points, you may have to compare the mouse coordinate against the points in the points list, looking for it being "close" to one of those?
@JonB Yes, we clearly have difference in our understanding of the meaning of point. To me a point added to a line series (QXYSeries) is a point. Anywhere on a line joining points is NOT a point.
The Qt code appears to treat anywhere on the line connecting points as a point - IMHO it is not.
Currently it emits the hovered signal text if over either any point I added, or if over the connecting lines. No hovered signal is emitted for anywhere else on the chart (which I think your comment about a point anywhere on the chart is suggesting).
I contend this is a bug.
-
@JonB Yes, we clearly have difference in our understanding of the meaning of point. To me a point added to a line series (QXYSeries) is a point. Anywhere on a line joining points is NOT a point.
The Qt code appears to treat anywhere on the line connecting points as a point - IMHO it is not.
Currently it emits the hovered signal text if over either any point I added, or if over the connecting lines. No hovered signal is emitted for anywhere else on the chart (which I think your comment about a point anywhere on the chart is suggesting).
I contend this is a bug.
@Perdrix said in QLineSeries::hovered:
which I think your comment about a point anywhere on the chart is suggesting
No, I did not intend to suggest that. My "point" was about the description. Remember the method belongs to
QLineSeries, not theQChart, so I would expect it to be connected with the lines drawn not the whole chart.Let's not argue about semantics. From the description it does not surprise me that the hover is activated when "either on a plotted point or at a point somewhere along the drawn connected lines even if not on a plotted point, but not anywhere else on the chart". That is probably what i would expect by default.
So it's not what you would expect. "I contend this is a bug." Up to you. I would have thought if you report it it would at best be "corrected" by a change in documentation not behaviour. But up to you.
I have suggested what you might like to do if you only want to act when hovering over actual, plotted points. Unless you/someone else knows of a better solution.
If you are not demanding hover-only then the methods of
QXYseriesconcerningpointLabelslook like they can be used to show something against the plotted points only. -
@Perdrix said in QLineSeries::hovered:
which I think your comment about a point anywhere on the chart is suggesting
No, I did not intend to suggest that. My "point" was about the description. Remember the method belongs to
QLineSeries, not theQChart, so I would expect it to be connected with the lines drawn not the whole chart.Let's not argue about semantics. From the description it does not surprise me that the hover is activated when "either on a plotted point or at a point somewhere along the drawn connected lines even if not on a plotted point, but not anywhere else on the chart". That is probably what i would expect by default.
So it's not what you would expect. "I contend this is a bug." Up to you. I would have thought if you report it it would at best be "corrected" by a change in documentation not behaviour. But up to you.
I have suggested what you might like to do if you only want to act when hovering over actual, plotted points. Unless you/someone else knows of a better solution.
If you are not demanding hover-only then the methods of
QXYseriesconcerningpointLabelslook like they can be used to show something against the plotted points only.