【问题标题】:QWT moving canvasQWT 移动画布
【发布时间】:2018-08-29 12:48:47
【问题描述】:

我正在为我的小部件使用 QWT 库,画布上有一些曲线,如下所示:

void Plot::addCurve1( double x, double y, const char *CurveName,
                      const char *CurveColor,const char *CurveType )
{
...
    *points1 << QPointF(x, y);
    curve1->setSamples( *points1 );
    curve1->attach( this );
...
}

所以,我所有的曲线都有相同的坐标系。我正在尝试构建导航界面,因此我可以将 step 放入 TextEdit(例如)并使用此步骤移动,或者我可以进入我定义的曲线的结束/开始。 我在 QwtPlotPanner 类中找到了方法,这给了我这样的机会:

double QWT_widget::move_XLeft()
{
    //getting step from TextEdit
    QString xValStr = _XNavDiscrepancies->toPlainText();
    double xVal = xVal.toDouble();
    // moveCanvas(int dx, int dy) - the method of QwtPlotPanner
    plot->panner->moveCanvas(xVal,0);
    x_storage = x_storage - xVal;
    return x_storage;
}

所以它工作正常,但是以像素为单位的位移,我需要将它粘贴到我定义的曲线和它的坐标系上。 Qwt 用户指南告诉我们:

根据 dx/dy 调整启用的轴 参数 dx x 方向的像素偏移 dy y方向的像素偏移量

这是我找到的唯一信息。如何将像素步转换为我的坐标系统步?我需要走到曲线的末端,所以我应该返回曲线的最后一个 QPointF(x,y) 并将其转换为像素步长?或者也许我使用了错误的类/方法? 非常感谢:)

【问题讨论】:

    标签: qt qwt


    【解决方案1】:

    感谢@Pavel Gridin: (https://ru.stackoverflow.com/a/876184/251026)

    "从像素到坐标的转换有两个 方法:QwtPlot::transform 和 QwtPlot::invTransform"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-14
      • 1970-01-01
      相关资源
      最近更新 更多