ddee897:想问一下,使用QCustomPlot绘图,能实现鼠标在曲线上移动时,动态显示xy值吗
connect(this,&CurvePlot::mouseMove,this,&CurvePlot::ShowInfo);
void CurvePlot::ShowInfo(QMouseEvent *event)
{
double xx=this->xAxis->pixelToCoord(event->x());
double yx=this->yAxis->pixelToCoord(event->y());
QString str,strToolTip;
str = QString("%L1").arg(xx,0,'f',0);
strToolTip+="LBA: ";
strToolTip+=str;
strToolTip+="\n";
str = QString("%L1").arg(yx,0,'f',0);
strToolTip+=str;
QToolTip::showText(cursor().pos(),strToolTip,this);
}
类似于这样