【问题标题】:Convert canvas coordinates to coordinates of the external widget将画布坐标转换为外部小部件的坐标
【发布时间】:2019-08-24 23:46:57
【问题描述】:

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

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

绘图.cpp

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

MainWidget.cpp

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

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

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

【问题讨论】:

  • 好吧,看起来plot_->transform 总是给出与画布顶部对应的相同坐标,无论我传递什么值。

标签: c++ qt qwt


【解决方案1】:

好的,我必须使用来自QwtPlot 的方法canvasMap

【讨论】:

    猜你喜欢
    • 2011-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-02
    • 2015-03-13
    • 2021-06-17
    • 1970-01-01
    • 2018-05-25
    相关资源
    最近更新 更多