Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Find Data Value with Mouse on a QtChart
Forum Updated to NodeBB v4.3 + New Features

Find Data Value with Mouse on a QtChart

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 2.0k Views
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hey everyone,

    Hope all is well. Currently, I have been working on an app that uses QtCharts and QChartView. No issues thus far with most of the features I am trying to implement, as I have been able to find documentation or have been helped by this wonderful community. However, I do have one question, as I've hit a roadblock.

    Currently, I am trying to implement a feature in which the mouse can hover (and possibly even click) on individual data points to get data readings. Something akin to how the Google Stock Price Charts work:

    Graph Example.gif
    Source: (https://www.google.com/finance/quote/NVDA:NASDAQ?sa=X&sqi=2&ved=2ahUKEwj1rOX__dP0AhWNVN8KHYbDDlkQ3ecFegQIIxAe)

    As the gif above shows, I'd like to have some sort of feature where it displays the data point in relation to the x-location of the mouse.

    What would I need to do to start this? I tried using a mouseMoveEvent function but the app crashed; that is the only thing I've tried so far. Thank you, in advance, for your time and consideration!

    1 Reply Last reply
    1
    • M Offline
      M Offline
      MrShawn
      wrote on last edited by
      #2

      Hi @WesLow

      Simply use the hovered signal. It will give you the point x y data as well.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @MrShawn said in Find Data Value with Mouse on a QtChart:

        hovered

        So would I need to do something like this?

        connect(seriesName, QXYSeries::hovered, chartName, displayPlotValueFunction);
        

        Or would I need to try something else? Confused about the last parameter. Or, am I overcomplicating things? Thank you for your response!

        jsulmJ 1 Reply Last reply
        0
        • ? A Former User

          @MrShawn said in Find Data Value with Mouse on a QtChart:

          hovered

          So would I need to do something like this?

          connect(seriesName, QXYSeries::hovered, chartName, displayPlotValueFunction);
          

          Or would I need to try something else? Confused about the last parameter. Or, am I overcomplicating things? Thank you for your response!

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @WesLow said in Find Data Value with Mouse on a QtChart:

          Confused about the last parameter

          Last parameter is the pointer to slot:

          connect(seriesName, &QXYSeries::hovered, yourClassInstancePointer, &YourClassName::displayPlotValueFunction);
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          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 Extensions
          • Unsolved