北京优化网站公司,顺德搜索seo网络推广,中小型网站建设方案,借用备案网站跳转做淘宝客提示#xff1a;文章写完后#xff0c;目录可以自动生成#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、确定文件组成#xff1f;1. 复制新文件2.新建ui窗口 二、实际操作2.1 新建Ui窗口#xff0c;要添加带.h的否则跳转错误2.2添加文件到.h2.3 添加文件cpp 三… 提示文章写完后目录可以自动生成如何生成可参考右边的帮助文档 文章目录 前言一、确定文件组成1. 复制新文件2.新建ui窗口 二、实际操作2.1 新建Ui窗口要添加带.h的否则跳转错误2.2添加文件到.h2.3 添加文件cpp 三、 自适应曲线y轴总结 前言
提示这里可以添加本文要记录的大概内容
从之前的工程中移植曲线显示代码到另外一个工程 提示以下是本篇文章正文内容下面案例可供参考
一、确定文件组成
1. 复制新文件 将文件添加到工程 2.新建ui窗口
右键 Forms 选择新建 添加控件
新建一个mainwidget 来添加工具 升级窗口 添加工程中 QT charts
二、实际操作
2.1 新建Ui窗口要添加带.h的否则跳转错误 添加控件 提升控件 2.2添加文件到.h #ifndef QCHARTV_H
#define QCHARTV_H#include QMainWindow
#include QtCharts //必须这么设置
#includeQMouseEvent
#includeqwchartview.hnamespace Ui {
class qchartV;
}class qchartV : public QMainWindow
{Q_OBJECTpublic:explicit qchartV(QWidget *parent 0);~qchartV();QChart *m_chart; //创建图像显示对象QLineSeries *m_series;//创建线QChartView *chartView ;//创建图表QValueAxis *axisX ;QValueAxis *axisY ;private slots:void on_acZoomReset_triggered();void on_acQuit_triggered();void on_acZoomIn_triggered();void on_acZoomOut_triggered();private:Ui::qchartV *ui;
};#endif // QCHARTV_H
2.3 添加文件cpp #include qchartv.h#include qwchartview.h#include ui_qchartv.h#include QMenu
#include QMenuBar
#include QToolBar
#includeQAction
#includeQDebugqchartV::qchartV(QWidget *parent) :QMainWindow(parent),ui(new Ui::qchartV)
{ui-setupUi(this);ui-centralwidget-setMouseTracking(true);ui-graphicsView-setMouseTracking(true);this-setMouseTracking(true);//必须开启此功能// ui-toolBar-actions();setWindowTitle(xxxxxxxx);createChart();//创建图表labXYValue new QLabel(X, Y ); //状态栏显示鼠标点的坐标labXYValue-setMinimumWidth(200);// ui-statusBar-addWidget(labXYValue);ui-statusbar-addWidget(labXYValue);QObject::connect(ui-graphicsView,SIGNAL(mouseMovePoint(QPoint)),this, SLOT(on_mouseMovePoint(QPoint))); //鼠标移动事件
}qchartV::~qchartV()
{delete ui;
}void qchartV::on_acZoomReset_triggered()
{}void qchartV::on_acQuit_triggered()
{}void qchartV::on_acZoomIn_triggered()
{}void qchartV::on_acZoomOut_triggered()
{}
三、 自适应曲线y轴
思路判断将传进来比当前最大值的数设定为最大值
总结
重点 1.新建带.h的ui窗口在里面命名并添加控件作为显示用 2.拷贝文件qwchartview.cpp qwchartview.h 里面有重新对鼠标等的控制 3.