Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to add hover for lines on a QChart



  • I'd like to add tooltip hover to expose the X/Y values over any line in a QChart. I'm trying to follow the example "callout" that ships with my Qt-12.6.
    For starters my chart GUI uses

    class HtcChart : public QMainWindow
    {
        Q_OBJECT
    
    and the example uses
    class Callout : public QGraphicsItem
    { 
    

    My QMainwindow includes buttons and the QGraphicsItem doesn't.

    I'm kind of lost in translating what I need to get into my HtcChart.

    Maybe one piece at a time.

    What do I need to add to my QChart/subclassed QChart construction to capture the hover.

    The example connects signals & slots as series are added and I have an iterator where I add series lines so I have a place to do the connections, I'm just really not sure what else needs to be in place for the rest of it to work.

    Any advice or pointers or other examples would be much appreciated.

    Thanks - Mike



  • How about a basic tip?
    I construct a QChart and render it on a QMainWindow using

    chartView = new QChartView(_chart);
    

    using baby steps here, I figured I could trap the chartViewws-> mouseMoveEvent by connecting it up to a slot:

    connect(this, SIGNAL(chartView->mouseMoveEvent(QMouseEvent*)),  this,SLOT(showPointToolTip(QMouseEvent*)));
    

    but I get

    No such signal HtcChart::chartView->mouseMoveEvent(QMouseEvent*)