QtDataVisualization Q3DSurface绘制曲面图

一、效果图
QtDataVisualization Q3DSurface绘制曲面图_第1张图片
二、代码

 1     //创建一个三维曲面对象
 2     Q3DSurface surface;
 3     surface.setFlags(surface.flags() ^ Qt::FramelessWindowHint);
 4     //创建数据对象
 5     QSurfaceDataArray *data = new QSurfaceDataArray;
 6     QSurfaceDataRow *dataRow1 = new QSurfaceDataRow;
 7     QSurfaceDataRow *dataRow2 = new QSurfaceDataRow;
 8     //为数据对象赋值
 9     *dataRow1 << QVector3D(0.0f, 0.1f, 0.5f) << QVector3D(1.0f, 0.5f, 0.5f);
10     *dataRow2 << QVector3D(0.0f, 1.8f, 1.0f) << QVector3D(1.0f, 1.2f, 1.0f);
11     *data << dataRow1 << dataRow2;
12     //创建序列,加入数据,添加到Q3DSurface
13     QSurface3DSeries *series = new QSurface3DSeries;
14     series->dataProxy()->resetArray(data);
15     surface.addSeries(series);
16     surface.show();

 

你可能感兴趣的:(QtDataVisualization Q3DSurface绘制曲面图)