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?
Forum Update on Monday, May 27th 2025

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

    JonBJ 1 Reply Last reply
    0
    • S sys1

      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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on 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 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.

        Pl45m4P 1 Reply Last reply
        0
        • S sys1

          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.

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on 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

          • Login

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