显示鼠标上的绘图值。 - 检测散点 [英] Display the plot values on mouse over. - Detect Scatter points

查看:239
本文介绍了显示鼠标上的绘图值。 - 检测散点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 QCustomPlot 上显示不同点的绘图值,其中我有一个线样式 lsLine 。我知道我可以在 QCustomPlot 上设置鼠标悬停信号,但是它不会真正帮助,因为我只需要通知鼠标在我的绘制线。我的问题是有什么办法找出是否鼠标在我的分散点。

I am attempting to display the plot values of different points on my QCustomPlot in which I have a Line style of lsLine. I know i could set a mouse over signal on the QCustomPlot but that wont really help since I just need to be informed when the mouse is over my plotted line.My question is is there any way to find out if the mouse is over my scatter point. Is there a signal i could connect to that would tell me when the mouse is over a scatter point ?

推荐答案

重新实现 QCustomPlot :: mouseMoveEvent 或连接到 QCustomPlot :: mouseMove

然后使用轴< coordToPixel 将(光标)像素坐标翻译为绘图坐标并在 QCPDataMap code> QMap :: lowerBound(cursorX)。

Then use axes' coordToPixel to translate (cursor) pixel coords to plot coords and search nearest points in your QCPDataMap with QMap::lowerBound(cursorX).

这篇关于显示鼠标上的绘图值。 - 检测散点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆