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. How can I do mouse click event on graph using QChartView?

How can I do mouse click event on graph using QChartView?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 2.6k 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.
  • S Offline
    S Offline
    sys1
    wrote on 18 Oct 2020, 15:33 last edited by sys1
    #1

    I created a QChartView on top of a grid layout to draw the graph.(
    I referenced the Creator's sample code.)

    When I click this graph, I want to display the mouse click position on the text label in the main window.

    I inherited QChartView and created a ChartView class and defined the mousePressEvent() function, but the mouse click did not work.

    Not sure what i am missing
    It would be appreciated if you uploaded the example code that can be operated.

    I'm using C++/Window/Visual Studio 2019/Qt 5.15.1

    Thank you

    J 1 Reply Last reply 18 Oct 2020, 16:07
    0
    • S sys1
      18 Oct 2020, 15:33

      I created a QChartView on top of a grid layout to draw the graph.(
      I referenced the Creator's sample code.)

      When I click this graph, I want to display the mouse click position on the text label in the main window.

      I inherited QChartView and created a ChartView class and defined the mousePressEvent() function, but the mouse click did not work.

      Not sure what i am missing
      It would be appreciated if you uploaded the example code that can be operated.

      I'm using C++/Window/Visual Studio 2019/Qt 5.15.1

      Thank you

      J Offline
      J Offline
      JonB
      wrote on 18 Oct 2020, 16:07 last edited by
      #2

      @sys1

      I want to display the mouse click position

      Don't know about your mousePressEvent(). But when you get it working you might be interested in https://stackoverflow.com/questions/44067831/get-mouse-coordinates-in-qchartviews-axis-system.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sys1
        wrote on 19 Oct 2020, 06:05 last edited by
        #3

        Thank you

        But, The mouse press event itself doesn't seem to work.

        So I want an example code with a mouse press event action.

        P 1 Reply Last reply 19 Oct 2020, 13:29
        0
        • S sys1
          19 Oct 2020, 06:05

          Thank you

          But, The mouse press event itself doesn't seem to work.

          So I want an example code with a mouse press event action.

          P Offline
          P Offline
          Pl45m4
          wrote on 19 Oct 2020, 13:29 last edited by
          #4

          @sys1

          Why not? What is happening? How did you implement it?

          https://doc.qt.io/qt-5/qchartview.html#mousePressEvent


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          0

          1/4

          18 Oct 2020, 15:33

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved