Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLineSeries::hovered
Qt 6.12 LTS is out! See what's new in the release blog

QLineSeries::hovered

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    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.

    PerdrixP 1 Reply Last reply
    1
    • PerdrixP Perdrix

      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.

      PerdrixP Offline
      PerdrixP Offline
      Perdrix
      wrote on last edited by
      #2

      I still think it should not behave as it does. Could someone who knows please comment.

      Thanks

      JonBJ 1 Reply Last reply
      0
      • PerdrixP Perdrix

        I still think it should not behave as it does. Could someone who knows please comment.

        Thanks

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @Perdrix
        What type is ChartTab? 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 point anywhere 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?

        PerdrixP 1 Reply Last reply
        0
        • JonBJ JonB

          @Perdrix
          What type is ChartTab? 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 point anywhere 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?

          PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote on last edited by
          #4

          @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.

          JonBJ 1 Reply Last reply
          0
          • PerdrixP Perdrix

            @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.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @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 the QChart, 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 QXYseries concerning pointLabels look like they can be used to show something against the plotted points only.

            PerdrixP 1 Reply Last reply
            0
            • JonBJ JonB

              @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 the QChart, 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 QXYseries concerning pointLabels look like they can be used to show something against the plotted points only.

              PerdrixP Offline
              PerdrixP Offline
              Perdrix
              wrote on last edited by Perdrix
              #6

              @JonB This one looks like a point of view question and I'm not going to press the issue here.

              I've opened:

              https://bugreports.qt.io/browse/QTBUG-114996

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt
              • Unsolved