将画布坐标转换为外部微件的坐标

Convert canvas coordinates to coordinates of the external widget

本文关键字:坐标 外部 转换 布坐标      更新时间:2023-10-16

我正在构建一个绘图,需要根据位于画布中的点的 Y 轴值链接位于父小部件中的标签 (QwtPlotCanvas(。

我尝试了很多方法,只有一种方法显示了一些或多或少合理的数字:plot->transform((,然后在父小部件中显示mapTo((。

剧情.cpp

QPoint(plot_->transform(QwtPlot::xBottom, pointsToMap.x()), plot_->transform(QwtPlot::yLeft, pointsToMap.y()));

主小部件.cpp

auto points = graph->getPlot()->canvas()->mapTo(this, graph->getPointsToMap());

我得到一个与画布顶部相对应的坐标。

我希望坐标在主小部件中的 Y 偏移量与画布中的坐标相同。

好的,我不得不使用QwtPlot canvasMap的方法。