Qwt使用之QwtPlot
来源:互联网 发布:工资制作软件 编辑:程序博客网 时间:2024/05/17 10:41
QwtPlot是用来绘制二维图像的widget。在它的画板上可以无限制的显示绘画组件。绘画组件可以是曲线(QwtPlotCurve)、标记(QwtPlotMarker)、网格(QwtPlotGrid)、或者其它从QwtPlotItem继承的组件。
QwtPlot拥有4个axes(轴线)
yLeft
Y axis left of the canvas.yRight Y axis right of the canvas.xBottom X axis below the canvas.xTop X axis above the canvas.常用函数接口
setAxisTitle设置轴标题enableAxis主要是显示xTop,yRight坐标轴setAxisMaxMajor设置某个某个坐标轴扩大比例尺的最大间隔数目setAxisMaxMinor设置某个某个坐标轴缩小比例尺的最大间隔数目setAxisScale禁用自动缩放比例尺,为某个坐标轴指定一个修改的比例尺insertLegend添加图例(标注)
常用组件
QwtPlotCurve曲线QwtPlotMarker标记QwtPlotGrid网格QwtPlotHistogram直方图other从QwtPlotItem继承的组件
QwtPlotItemplot能显示的类,如果想要实现自己绘画图形,要继承此类实现rtti和draw接口QwtPlotPanner平移器 (用鼠标左键平移)QwtPlotMagnifier 放大器 (用鼠标滚轮缩放)QwtPlotCanvas画布QwtScaleMap比例图---可以提供一个逻辑区域到实际区域的坐标转换QwtScaleWidget比例窗口QwtScaleDiv比例布局QwtLegent标注QwtPlotLayout布局管理器QwtScaleDraw自画坐标轴
QwtPlotCure简介
常见接口
setPen设置画笔setData设置曲线的数据setStyle设置曲线形式,点、直线、虚线等等setCurveAttribute设置曲线属性,一般设置Fittedattch把曲线附加到QwlPlot上
下面看一个小例子,结果如下:
源代码:
- #include <QtGui/QApplication>
- #include <Qt/qmath.h>
- #include <QVector>
- #include <qwt_plot.h>
- #include <qwt_plot_curve.h>
- #include <qwt_plot_magnifier.h>
- #include <qwt_plot_panner.h>
- #include <qwt_legend.h>
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- QwtPlot plot(QwtText("CppQwtExample1"));
- plot.resize(640,400);
- //设置坐标轴的名称
- plot.setAxisTitle(QwtPlot::xBottom, "x->");
- plot.setAxisTitle(QwtPlot::yLeft, "y->");
- //设置坐标轴的范围
- plot.setAxisScale(QwtPlot::xBottom, 0.0, 2.0 * M_PI);
- plot.setAxisScale(QwtPlot::yLeft, -1.0, 1.0);
- //设置右边标注
- plot.insertLegend(new QwtLegend(), QwtPlot::RightLegend);
- //使用滚轮放大/缩小
- (void) new QwtPlotMagnifier( plot.canvas() );
- //使用鼠标左键平移
- (void) new QwtPlotPanner( plot.canvas() );
- //计算曲线数据
- QVector<double> xs;
- QVector<double> ys;
- for (double x = 0; x < 2.0 * M_PI; x+=(M_PI / 10.0))
- {
- xs.append(x);
- ys.append(qSin(x));
- }
- //构造曲线数据
- QwtPointArrayData * const data = new QwtPointArrayData(xs, ys);
- QwtPlotCurve curve("Sine");
- curve.setData(data);//设置数据
- curve.setStyle(QwtPlotCurve::Lines);//直线形式
- curve.setCurveAttribute(QwtPlotCurve::Fitted, true);//是曲线更光滑
- curve.setPen(QPen(Qt::blue));//设置画笔
- curve.attach(&plot);//把曲线附加到plot上
- plot.show();
- return a.exec();
- }
0 0
- Qwt使用之QwtPlot
- Qwt使用之QwtPlot
- Qwt使用之QwtPlot
- Qwt使用之QwtPlot
- 关于Qwt的使用-QwtPlot
- qwt-QwtPlot
- Qwt源码解读之QwtPlot类
- Qwt源码解读之QwtPlot类
- 重载QwtPlot类编译错误,需宏定义QWT_DLL才能使用QWT抛出类
- 重载QwtPlot类编译错误,需宏定义QWT_DLL才能使用QWT抛出类
- QWT错误static struct QMetaObject const QwtPlot
- QwtPlot解读---from Qwt-6.6.1
- QWT错误static struct QMetaObject const QwtPlot
- QWT使用之QwtPlotCurve
- QwtPlot之绘制统计图
- QwtPlot简单使用
- qwtplot
- QWtplot
- js实现分页问题
- UVA - 10300 Ecological Premium(水题)
- 发的公司大股东是双方的会发生的
- java基础巩固系列(二):Integer与int之间的区别
- 乘法口诀C 语言写的—
- Qwt使用之QwtPlot
- HDU 2255 奔小康赚大钱(二分图最优匹配:模板题)
- jquery easyui layout 怎样添加和删除面板
- Java读入txt,比较程序(第一个小程序)
- usb端口监控软件
- 横屏启动画面看不到怎么办
- Cannot find the declaration of element 'beans'. 的解决方法
- C语言写俄罗斯方块源码—
- WP系统推广难的原因之一之我见