Qwt 和 QwtSeriesData

发布于 2024-12-20 08:33:30 字数 241 浏览 3 评论 0原文

我最初使用C编程语言。但是现在,我需要使用Qt编程(顺便说一句,Qt就像一个梦)。我将一步步深入。但是我的C++面向对象知识比较薄弱,希望能够更强一些。现在我必须使用 Qwt,并且我陷入了 QwtSeriesData 对象。我需要知道如何为该对象设置一系列数据,以便使用 QwtPlot 绘制曲线。

例如我的数据如下所示,如何将它们设置到 QwtSeriesData 中。

浮动x[300]; 浮动y[300];

谢谢。

I originally use C Programming language. But Now, I need to use Qt programming (by the way, Qt is like a dream). I am going to more depth step by step. But my C++ object oriented knowledge is weak, I hope that it will be stronger. Nowadays I have to use Qwt and I stucked in QwtSeriesData object. I need to know how can I set a series of data to this object in order to draw a curve with using QwtPlot.

For example my data is like below, how can I set them into QwtSeriesData.

float x[300];
float y[300];

Thanks.

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

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

发布评论

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

评论(2

心凉 2024-12-27 08:33:30

我的答案是最新的 qwt 版本 6.xx(当前最新)
注意:qwt 内部使用 double 来表示数据,而不是 float。因此,您要么应该使用 double,要么需要实现自己的 QwtSeriesData 实现,该实现将 float 保留在内存中,但为外部组件的请求提供 double (这是一种非常糟糕的做法)

您可以使用由 QwtSeriesData 提供的子类之一重量:
QwtCPointerDataQwtPointArrayData

My answer is for latest qwt version 6.x.x (latest for current moment)
Note: qwt internally uses double for data representation, not float. So you either should use double or you would need to implement your own QwtSeriesData implementation which holds float in memory but provides double for requests of external components (that's a really bad way of doing things)

You can use one of subclasses of QwtSeriesData provided by the qwt:
QwtCPointerData or QwtPointArrayData.

北斗星光 2024-12-27 08:33:30

我就是这样做的:

QwtPlotCurve* curve = new QwtPlotCurve;
QPolygonF points;
for(unsigned int i = 0; i < 300; i++)
{
  points << QPointF(x[i], y[i]);
}
curve->setSamples(points);

然后您需要将曲线附加到绘图上。

This is how I do it:

QwtPlotCurve* curve = new QwtPlotCurve;
QPolygonF points;
for(unsigned int i = 0; i < 300; i++)
{
  points << QPointF(x[i], y[i]);
}
curve->setSamples(points);

you then need to attach the curve to the plot.

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