Qwt - 如何使用 QwtPlotPicker 获取选择点索引

发布于 2024-12-21 21:41:54 字数 305 浏览 7 评论 0原文

我使用 QwtPlot 绘制复杂数据,因此,我重新实现 QwtSeriesData 将数据转换为 QPointF。 “sample(int)”将 MyObject 转换为 QPointf。我的 QwtSeriesData 数据管理

myVector=vector<MyObject>;

现在,我需要选择绘制到我的图中的点。我尝试使用 QwtPlotPicker 但它只返回 QPointF。

如何获取所选点的索引“idx”以获得myObject=myVector[idx]

I plot complex data using QwtPlot, so, I reimplement QwtSeriesData for converting my data into QPointF. The "sample(int)" converts MyObject to QPointf. My QwtSeriesData data manages a

myVector=vector<MyObject>;

Now, I need to select point drawn into my plot. I try to use QwtPlotPicker but it only returns a QPointF.

How to get the index "idx" of the selected point in order to get myObject=myVector[idx]?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妳是的陽光 2024-12-28 21:41:54

使用曲线中的closestPoint()方法。

int QwtPlotCurve::closestPoint  (   const QPoint &      pos,
    double *    dist = NULL 
) 

它将返回曲线中最近点的 id!

希望这对您有帮助。

Use the closestPoint() method in the curve.

int QwtPlotCurve::closestPoint  (   const QPoint &      pos,
    double *    dist = NULL 
) 

It will return the id of the closest point in the curve!

Hope this helps you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文