c++ - How to enable mouse popup in QtCharts? -


i need small popup shown when mouse hovers on series in qtchart.

highcharts (javascript) has nice examples one:

enter image description here

how can implement qtcharts?

i cannot find documentation on implementing popups.

as far know have yourself. needed same , used simple qwidget embedded in qgraphicsproxywidget added qgraphicsscene of chart view.

qwidget *popup = new mypopupwidget; qchartview v; qgraphicsproxywidget *proxy = v.scene()->addwidget(popup);  // if want drop shadow can use qgraphicsdropshadoweffect qgraphicsdropshadoweffect* shadow   = new qgraphicsdropshadoweffect(); shadow->setoffset(0, 4); shadow->setblurradius(8); proxy->setgraphicseffect(shadow); 

while nice , simple, positioning of popup actual work. simple solutions weren't enough me. example there signals if mouse hits qgraphicsitem (all line items of charts qgraphicsitems) small , want react on actual data points, not on line segments.

you can override mousemove(qmousemoveevent *) function , check mouse position against data points , adjust popup (show/hide, positioning). if have many points slow, used spatial grid , assigned data points grid cells initially. need check against points within grid cells around mouse position.

i didn't find better solution.


Comments