Browse Source

Initial commit

lennlouis 4 months ago
parent
commit
aa498835f8
19 changed files with 2256 additions and 0 deletions
  1. BIN
      images/132.bmp
  2. BIN
      images/3.ico
  3. BIN
      images/39.ico
  4. BIN
      images/414.bmp
  5. BIN
      images/416.bmp
  6. BIN
      images/418.bmp
  7. BIN
      images/43.ico
  8. BIN
      images/828.bmp
  9. BIN
      images/dis3.ico
  10. BIN
      images/f14.ico
  11. 11 0
      main.cpp
  12. 578 0
      mainwindow.cpp
  13. 142 0
      mainwindow.h
  14. 1128 0
      mainwindow.ui
  15. 92 0
      qwdialogpen.cpp
  16. 30 0
      qwdialogpen.h
  17. 234 0
      qwdialogpen.ui
  18. 13 0
      res.qrc
  19. 28 0
      samp9_2.pro

BIN
images/132.bmp


BIN
images/3.ico


BIN
images/39.ico


BIN
images/414.bmp


BIN
images/416.bmp


BIN
images/418.bmp


BIN
images/43.ico


BIN
images/828.bmp


BIN
images/dis3.ico


BIN
images/f14.ico


+ 11 - 0
main.cpp

@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+
+    return a.exec();
+}

+ 578 - 0
mainwindow.cpp

@@ -0,0 +1,578 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include    "qwdialogpen.h"
+#include  <QRandomGenerator>
+
+// 若MSVC 编译版本错误,修改 msvc-version.conf 文件
+// 解决MSVC编译时,界面汉字乱码的问题
+#if _MSC_VER >= 1600     //MSVC2015>1899,    MSVC_VER= 14.0
+#pragma execution_character_set("utf-8")
+#endif
+
+
+void MainWindow::createChart()
+{//创建图表的各个部件
+    QChart *chart = new QChart();
+    chart->setTitle(tr("简单函数曲线"));
+//    chart->setAcceptHoverEvents(true);
+    ui->chartView->setChart(chart);
+    ui->chartView->setRenderHint(QPainter::Antialiasing);
+
+    QLineSeries *series0 = new QLineSeries();
+    QLineSeries *series1 = new QLineSeries();
+    series0->setName("Sin曲线");
+    series1->setName("Cos曲线");
+
+    curSeries=series0; //当前序列
+
+    QPen    pen;
+    pen.setStyle(Qt::DotLine);//Qt::SolidLine, Qt::DashLine, Qt::DotLine, Qt::DashDotLine
+    pen.setWidth(2);
+    pen.setColor(Qt::red);
+    series0->setPen(pen); //折线序列的线条设置
+
+    pen.setStyle(Qt::SolidLine);//Qt::SolidLine, Qt::DashLine, Qt::DotLine, Qt::DashDotLine
+    pen.setColor(Qt::blue);
+    series1->setPen(pen);//折线序列的线条设置
+
+    chart->addSeries(series0);
+    chart->addSeries(series1);
+
+    QValueAxis *axisX = new QValueAxis;
+    curAxis=axisX; //当前坐标轴
+    axisX->setRange(0, 10); //设置坐标轴范围
+    axisX->setLabelFormat("%.1f"); //标签格式
+    axisX->setTickCount(11); //主分隔个数
+    axisX->setMinorTickCount(4);
+    axisX->setTitleText("time(secs)"); //标题
+//    axisX->setGridLineVisible(false);
+
+    QValueAxis *axisY = new QValueAxis;
+    axisY->setRange(-2, 2);
+    axisY->setTitleText("value");
+    axisY->setTickCount(5);
+    axisY->setLabelFormat("%.2f"); //标签格式
+//    axisY->setGridLineVisible(false);
+    axisY->setMinorTickCount(4);
+
+//  下面4行语句在Qt5.12.1里编译时提示过时(deprecated)了,应使用另外一种方法添加坐标轴
+//    chart->setAxisX(axisX, series0); //添加X坐标轴
+//    chart->setAxisX(axisX, series1); //添加X坐标轴
+//    chart->setAxisY(axisY, series0); //添加Y坐标轴
+//    chart->setAxisY(axisY, series1); //添加Y坐标轴
+
+//另一种实现设置坐标轴的方法,在Qt 5.12.1里编译时不会提示过时
+    chart->addAxis(axisX,Qt::AlignBottom); //坐标轴添加到图表,并指定方向
+    chart->addAxis(axisY,Qt::AlignLeft);
+
+    series0->attachAxis(axisX); //序列 series0 附加坐标轴
+    series0->attachAxis(axisY);
+
+    series1->attachAxis(axisX);//序列 series1 附加坐标轴
+    series1->attachAxis(axisY);
+
+    foreach (QLegendMarker* marker, chart->legend()->markers()) {
+        QObject::disconnect(marker, SIGNAL(clicked()), this, SLOT(on_LegendMarkerClicked()));
+        QObject::connect(marker, SIGNAL(clicked()), this, SLOT(on_LegendMarkerClicked()));
+    }
+}
+
+void MainWindow::prepareData()
+{//为序列生成数据
+    QLineSeries *series0=(QLineSeries *)ui->chartView->chart()->series().at(0);
+    QLineSeries *series1=(QLineSeries *)ui->chartView->chart()->series().at(1);
+
+    series0->clear(); //清除数据
+    series1->clear();
+
+//    qsrand(QTime::currentTime().second());//随机数初始化
+    qreal   t=0,y1,y2,intv=0.1;
+    qreal   rd;
+    int cnt=100;
+    for(int i=0;i<cnt;i++)
+    {
+//        rd=(qrand() % 10)-5; //随机数,-5~+5
+        rd= QRandomGenerator::global()->bounded(-5,6);  //
+        y1=qSin(t)+rd/50;
+        *series0<<QPointF(t,y1);  //序列添加数据点
+//        series0->append(t,y1);  //序列添加数据点
+
+//        rd=(qrand() % 10)-5; //随机数,-5~+5
+        rd= QRandomGenerator::global()->bounded(-5,6);  //
+
+        y2=qCos(t)+rd/50;
+//        series1->append(t,y2); //序列添加数据点
+        *series1<<QPointF(t,y2); //序列添加数据点
+
+        t+=intv;
+    }
+}
+
+void MainWindow::updateFromChart()
+{ //从图表上获取数据更新界面显示
+    QChart  *aChart;
+    aChart=ui->chartView->chart();  //获取chart
+
+    ui->editTitle->setText(aChart->title()); //图表标题
+
+    QMargins    mg=aChart->margins(); //边距
+    ui->spinMarginLeft->setValue(mg.left());
+    ui->spinMarginRight->setValue(mg.right());
+    ui->spinMarginTop->setValue(mg.top());
+    ui->spinMarginBottom->setValue(mg.bottom());
+}
+
+MainWindow::MainWindow(QWidget *parent) :
+    QMainWindow(parent),
+    ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+
+    createChart();//创建图表
+    prepareData();//生成数据
+    updateFromChart(); //从图表获得属性值,刷新界面显示
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+
+void MainWindow::on_LegendMarkerClicked()
+{
+    QLegendMarker* marker = qobject_cast<QLegendMarker*> (sender());
+
+    switch (marker->type())
+    {
+        case QLegendMarker::LegendMarkerTypeXY:
+        {
+            marker->series()->setVisible(!marker->series()->isVisible());
+            marker->setVisible(true);
+            qreal alpha = 1.0;
+            if (!marker->series()->isVisible())
+                alpha = 0.5;
+
+            QColor color;
+            QBrush brush = marker->labelBrush();
+            color = brush.color();
+            color.setAlphaF(alpha);
+            brush.setColor(color);
+            marker->setLabelBrush(brush);
+
+            brush = marker->brush();
+            color = brush.color();
+            color.setAlphaF(alpha);
+            brush.setColor(color);
+            marker->setBrush(brush);
+
+            QPen pen = marker->pen();
+            color = pen.color();
+            color.setAlphaF(alpha);
+            pen.setColor(color);
+            marker->setPen(pen);
+            break;
+        }
+        default:
+            break;
+    }
+
+
+}
+
+void MainWindow::on_actDraw_triggered()
+{ //重新生成数据
+    prepareData();//重新生成数据
+}
+
+void MainWindow::on_btnSetTitle_clicked()
+{ //设置图标标题文字
+    QString str=ui->editTitle->text();
+    ui->chartView->chart()->setTitle(str);
+}
+
+void MainWindow::on_btnSetTitleFont_clicked()
+{ //设置图标标题文字的字体
+    QFont font=ui->chartView->chart()->titleFont();
+    bool  ok=false;
+    font=QFontDialog::getFont(&ok,font);
+    if (ok)
+        ui->chartView->chart()->setTitleFont(font);
+}
+
+void MainWindow::on_btnSetMargin_clicked()
+{//设置图标的4个边距
+    QMargins    mgs;
+    mgs.setLeft(ui->spinMarginLeft->value());
+    mgs.setRight(ui->spinMarginRight->value());
+    mgs.setTop(ui->spinMarginTop->value());
+    mgs.setBottom(ui->spinMarginBottom->value());
+    ui->chartView->chart()->setMargins(mgs);
+}
+
+void MainWindow::on_chkPointVisible_clicked(bool checked)
+{//序列的数据点是否可见
+    curSeries->setPointsVisible(checked);
+}
+
+void MainWindow::on_chkPointLabelVisible_clicked(bool checked)
+{ //序列的数据点标签是否可见
+    curSeries->setPointLabelsVisible(checked);
+}
+
+void MainWindow::on_btnSeriesName_clicked()
+{ //设置序列名称
+    curSeries->setName(ui->editSeriesName->text());
+    if (ui->radioSeries0->isChecked())
+        ui->radioSeries0->setText(ui->editSeriesName->text());
+    else
+        ui->radioSeries1->setText(ui->editSeriesName->text());
+}
+
+void MainWindow::on_btnSeriesColor_clicked()
+{ //序列的曲线颜色
+    QColor  color=curSeries->color();
+
+    color=QColorDialog::getColor(color);
+    if (color.isValid())
+      curSeries->setColor(color);
+}
+
+void MainWindow::on_chkLegendVisible_clicked(bool checked)
+{//图例是否可见
+    ui->chartView->chart()->legend()->setVisible(checked);
+}
+
+void MainWindow::on_btnSetAxisRange_clicked()
+{ //设置坐标轴的坐标范围
+    curAxis->setRange(ui->spinAxisMin->value(),ui->spinAxisMax->value());
+}
+
+void MainWindow::on_spinTickCount_valueChanged(int arg1)
+{
+    curAxis->setTickCount(arg1);
+}
+
+void MainWindow::on_spinMinorTickCount_valueChanged(int arg1)
+{
+    curAxis->setMinorTickCount(arg1);
+}
+
+void MainWindow::on_radioX_clicked()
+{ //获取当前坐标轴
+// 在Qt 5.12.1中编译时提示 QChart::axisX()和QChart::axisY()函数过时,应使用 QChart::axes()函数
+//    if (ui->radioX->isChecked())
+//        curAxis=(QValueAxis*)ui->chartView->chart()->axisX();
+//    else
+//        curAxis=(QValueAxis*)ui->chartView->chart()->axisY();
+
+//  下面是针对Qt 5.12.1修改的代码
+    QList<QAbstractAxis*> axes;
+    if (ui->radioX->isChecked())
+        axes=ui->chartView->chart()->axes(Qt::Horizontal);
+    else
+        axes=ui->chartView->chart()->axes(Qt::Vertical);
+    curAxis=(QValueAxis*)axes[0];
+
+
+//获取坐标轴的各种属性,显示到界面上
+    ui->spinAxisMin->setValue(curAxis->min());
+    ui->spinAxisMax->setValue(curAxis->max());
+
+    ui->editAxisTitle->setText(curAxis->titleText());
+    ui->chkBoxAxisTitle->setChecked(curAxis->isTitleVisible());
+
+    ui->editAxisLabelFormat->setText(curAxis->labelFormat());
+    ui->chkBoxLabelsVisible->setChecked(curAxis->labelsVisible());
+
+    ui->chkGridLineVisible->setChecked(curAxis->isGridLineVisible());
+    ui->chkAxisLineVisible->setChecked(curAxis->isLineVisible());
+
+    ui->spinTickCount->setValue(curAxis->tickCount());
+    ui->chkAxisLineVisible->setChecked(curAxis->isLineVisible());
+
+    ui->spinMinorTickCount->setValue(curAxis->minorTickCount());
+    ui->chkMinorTickVisible->setChecked(curAxis->isMinorGridLineVisible());
+}
+
+void MainWindow::on_radioY_clicked()
+{
+    on_radioX_clicked();
+}
+
+void MainWindow::on_chkGridLineVisible_clicked(bool checked)
+{ //轴的网格线是否可见
+    curAxis->setGridLineVisible(checked);
+}
+
+void MainWindow::on_chkMinorTickVisible_clicked(bool checked)
+{ //次级刻度是否可见
+    curAxis->setMinorGridLineVisible(checked);
+}
+
+
+void MainWindow::on_chkBoxLegendBackground_clicked(bool checked)
+{//图例的背景是否可见
+    ui->chartView->chart()->legend()->setBackgroundVisible(checked);
+}
+
+void MainWindow::on_radioButton_clicked()
+{//图例的位置
+    ui->chartView->chart()->legend()->setAlignment(Qt::AlignTop);
+}
+
+void MainWindow::on_radioButton_2_clicked()
+{//图例的位置
+    ui->chartView->chart()->legend()->setAlignment(Qt::AlignBottom);
+}
+
+void MainWindow::on_radioButton_3_clicked()
+{//图例的位置
+    ui->chartView->chart()->legend()->setAlignment(Qt::AlignLeft);
+}
+
+void MainWindow::on_radioButton_4_clicked()
+{//图例的位置
+    ui->chartView->chart()->legend()->setAlignment(Qt::AlignRight);
+}
+
+void MainWindow::on_btnLegendFont_clicked()
+{ //图例的字体设置
+    QFont font=ui->chartView->chart()->legend()->font();
+    bool  ok=false;
+    font=QFontDialog::getFont(&ok,font);
+    if (ok)
+        ui->chartView->chart()->legend()->setFont(font);
+}
+
+void MainWindow::on_btnLegendlabelColor_clicked()
+{//图例的文字颜色设置
+    QColor  color=ui->chartView->chart()->legend()->labelColor();
+    color=QColorDialog::getColor(color);
+    if (color.isValid())
+        ui->chartView->chart()->legend()->setLabelColor(color);
+}
+
+void MainWindow::on_chkBoxVisible_clicked(bool checked)
+{ //坐标轴是否可见
+    curAxis->setVisible(checked);
+}
+
+
+void MainWindow::on_btnAxisSetTitle_clicked()
+{ //设置坐标轴的标题
+    curAxis->setTitleText(ui->editAxisTitle->text());
+}
+
+void MainWindow::on_btnAxisSetTitleFont_clicked()
+{ //设置坐标轴的标题的字体
+    QFont   font=curAxis->titleFont();
+
+    bool    ok=false;
+    font=QFontDialog::getFont(&ok,font);
+    if (ok)
+       curAxis->setTitleFont(font);
+}
+
+void MainWindow::on_chkBoxAxisTitle_clicked(bool checked)
+{ //轴标题是否可见
+    curAxis->setTitleVisible(checked);
+}
+
+void MainWindow::on_pushButton_clicked()
+{//设置坐标轴刻度标签的文字格式
+    curAxis->setLabelFormat(ui->editAxisLabelFormat->text());
+}
+
+void MainWindow::on_btnAxisLabelColor_clicked()
+{//设置坐标轴刻度标签的文字颜色
+    QColor   color=curAxis->labelsColor();
+
+    color=QColorDialog::getColor(color);
+    if (color.isValid())
+       curAxis->setLabelsColor(color);
+}
+
+void MainWindow::on_btnAxisLabelFont_clicked()
+{//设置坐标轴刻度标签的文字字体
+    QFont   font=curAxis->labelsFont();
+
+    bool    ok=false;
+    font=QFontDialog::getFont(&ok,font);
+    if (ok)
+       curAxis->setLabelsFont(font);
+}
+
+void MainWindow::on_chkBoxLabelsVisible_clicked(bool checked)
+{//轴的刻度标签是否可见
+   curAxis->setLabelsVisible(checked);
+}
+
+void MainWindow::on_btnGridLineColor_clicked()
+{ //网格线的颜色设置
+    QColor   color=curAxis->gridLineColor();
+
+    color=QColorDialog::getColor(color);
+    if (color.isValid())
+       curAxis->setGridLineColor(color);
+}
+
+void MainWindow::on_pushButton_10_clicked()
+{ //网格线的Pen设置
+    QPen    pen;
+    pen=curAxis->gridLinePen();
+
+    bool    ok=false;
+    pen=QWDialogPen::getPen(pen,ok);
+
+    if (ok)
+      curAxis->setGridLinePen(pen);
+}
+
+void MainWindow::on_chkAxisLineVisible_clicked(bool checked)
+{//刻度是否可见
+    curAxis->setLineVisible(checked);
+}
+
+void MainWindow::on_btnAxisLinePen_clicked()
+{
+    QPen    pen;
+    pen=curAxis->linePen();
+
+    bool    ok=false;
+    pen=QWDialogPen::getPen(pen,ok);
+
+    if (ok)
+      curAxis->setLinePen(pen);
+}
+
+
+void MainWindow::on_btnAxisLinePenColor_clicked()
+{
+    QColor   color=curAxis->linePenColor();
+
+    color=QColorDialog::getColor(color);
+    if (color.isValid())
+       curAxis->setLinePenColor(color);
+}
+
+void MainWindow::on_btnMinorColor_clicked()
+{//次级刻度网格线颜色
+    QColor   color=curAxis->minorGridLineColor();
+
+    color=QColorDialog::getColor(color);
+    if (color.isValid())
+       curAxis->setMinorGridLineColor(color);
+}
+
+void MainWindow::on_btnMinorPen_clicked()
+{//次级刻度线Pen设置
+    QPen    pen;
+    pen=curAxis->minorGridLinePen();
+
+    bool    ok=false;
+    pen=QWDialogPen::getPen(pen,ok);
+
+    if (ok)
+      curAxis->setMinorGridLinePen(pen);
+}
+
+void MainWindow::on_radioSeries0_clicked()
+{//获取当前数据序列
+    if (ui->radioSeries0->isChecked())
+        curSeries=(QLineSeries *)ui->chartView->chart()->series().at(0);
+    else
+        curSeries=(QLineSeries *)ui->chartView->chart()->series().at(1);
+//获取序列的属性值,并显示到界面上
+    ui->editSeriesName->setText(curSeries->name());
+    ui->chkSeriesVisible->setChecked(curSeries->isVisible());
+    ui->chkPointVisible->setChecked(curSeries->pointsVisible());
+    ui->sliderSeriesOpacity->setValue(curSeries->opacity()*10);
+    ui->chkPointLabelVisible->setChecked(curSeries->pointLabelsVisible());
+}
+
+void MainWindow::on_radioSeries1_clicked()
+{
+    on_radioSeries0_clicked();
+}
+
+
+void MainWindow::on_chkSeriesVisible_clicked(bool checked)
+{//序列是否可见
+    this->curSeries->setVisible(checked);
+}
+
+void MainWindow::on_btnSeriesPen_clicked()
+{//序列线条的Pen设置
+    bool    ok=false;
+    QPen    pen;
+    pen=curSeries->pen();
+
+    pen=QWDialogPen::getPen(pen,ok);
+
+    if (ok)
+      curSeries->setPen(pen);
+}
+
+void MainWindow::on_sliderSeriesOpacity_valueChanged(int value)
+{//序列的透明度
+    curSeries->setOpacity(value/10.0);
+}
+
+void MainWindow::on_btnSeriesLabColor_clicked()
+{//序列数据点标签颜色
+    QColor  color=curSeries->pointLabelsColor();
+
+    color=QColorDialog::getColor(color);
+    if (color.isValid())
+      curSeries->setPointLabelsColor(color);
+
+}
+
+void MainWindow::on_btnSeriesLabFont_clicked()
+{//序列数据点标签字体
+    QFont   font;
+    font=curSeries->pointLabelsFont();
+    bool    ok=false;
+    font=QFontDialog::getFont(&ok,font);
+    if (ok)
+        curSeries->setPointLabelsFont(font);
+}
+
+void MainWindow::on_radioSeriesLabFormat0_clicked()
+{ //序列数据点标签的显示格式
+    curSeries->setPointLabelsFormat("@yPoint");
+}
+
+void MainWindow::on_radioSeriesLabFormat1_clicked()
+{//序列数据点标签的显示格式
+    curSeries->setPointLabelsFormat("(@xPoint,@yPoint)");
+}
+
+void MainWindow::on_cBoxAnimation_currentIndexChanged(int index)
+{//动画效果
+    ui->chartView->chart()->setAnimationOptions(QChart::AnimationOptions(index));
+//    ui->chartView->chart()->setAnimationOptions(QChart::SeriesAnimations);
+//    ui->chartView->chart()->setAnimationOptions(QChart::AllAnimations);
+}
+
+
+void MainWindow::on_cBoxTheme_currentIndexChanged(int index)
+{ //图标的主题
+    ui->chartView->chart()->setTheme(QChart::ChartTheme(index));
+}
+
+void MainWindow::on_actZoomIn_triggered()
+{//放大
+    ui->chartView->chart()->zoom(1.2);//zoomIn();
+}
+
+void MainWindow::on_actZoomOut_triggered()
+{//缩小
+    ui->chartView->chart()->zoom(0.8);//zoomOut();
+}
+
+void MainWindow::on_actZoomReset_triggered()
+{//复位
+    ui->chartView->chart()->zoomReset();
+}

+ 142 - 0
mainwindow.h

@@ -0,0 +1,142 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include    <QMainWindow>
+
+#include    <QtCharts>
+
+QT_CHARTS_USE_NAMESPACE
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+private:
+    QLineSeries *curSeries; //当前序列
+
+    QValueAxis *curAxis; //当前坐标轴
+
+    void    createChart(); //创建图表
+    void    prepareData(); //更新数据
+    void    updateFromChart(); //从图表更新到界面
+
+public:
+    explicit MainWindow(QWidget *parent = 0);
+    ~MainWindow();
+
+private slots:
+    void on_LegendMarkerClicked(); //图例单击
+
+    void on_actDraw_triggered();
+
+    void on_btnSetTitle_clicked();
+
+    void on_btnSetTitleFont_clicked();
+
+    void on_btnSetMargin_clicked();
+
+    void on_chkPointVisible_clicked(bool checked);
+
+    void on_chkPointLabelVisible_clicked(bool checked);
+
+    void on_btnSeriesName_clicked();
+
+    void on_btnSeriesColor_clicked();
+
+    void on_chkLegendVisible_clicked(bool checked);
+
+    void on_btnSetAxisRange_clicked();
+
+    void on_spinTickCount_valueChanged(int arg1);
+
+    void on_spinMinorTickCount_valueChanged(int arg1);
+
+    void on_radioX_clicked();
+
+    void on_radioY_clicked();
+
+    void on_chkGridLineVisible_clicked(bool checked);
+
+    void on_chkMinorTickVisible_clicked(bool checked);
+
+    void on_chkBoxLegendBackground_clicked(bool checked);
+
+    void on_radioButton_clicked();
+
+    void on_radioButton_2_clicked();
+
+    void on_radioButton_3_clicked();
+
+    void on_radioButton_4_clicked();
+
+    void on_btnLegendFont_clicked();
+
+    void on_btnLegendlabelColor_clicked();
+
+    void on_chkBoxVisible_clicked(bool checked);
+
+    void on_btnAxisSetTitle_clicked();
+
+    void on_btnAxisSetTitleFont_clicked();
+
+    void on_chkBoxAxisTitle_clicked(bool checked);
+
+    void on_pushButton_clicked();
+
+    void on_btnAxisLabelColor_clicked();
+
+    void on_btnAxisLabelFont_clicked();
+
+    void on_chkBoxLabelsVisible_clicked(bool checked);
+
+    void on_btnGridLineColor_clicked();
+
+    void on_pushButton_10_clicked();
+
+    void on_chkAxisLineVisible_clicked(bool checked);
+
+    void on_btnAxisLinePen_clicked();
+
+    void on_btnAxisLinePenColor_clicked();
+
+    void on_btnMinorColor_clicked();
+
+    void on_btnMinorPen_clicked();
+
+    void on_radioSeries0_clicked();
+
+    void on_radioSeries1_clicked();
+
+    void on_chkSeriesVisible_clicked(bool checked);
+
+    void on_btnSeriesPen_clicked();
+
+    void on_sliderSeriesOpacity_valueChanged(int value);
+
+    void on_btnSeriesLabColor_clicked();
+
+    void on_btnSeriesLabFont_clicked();
+
+    void on_radioSeriesLabFormat0_clicked();
+
+    void on_radioSeriesLabFormat1_clicked();
+
+    void on_cBoxAnimation_currentIndexChanged(int index);
+
+    void on_cBoxTheme_currentIndexChanged(int index);
+
+    void on_actZoomIn_triggered();
+
+    void on_actZoomOut_triggered();
+
+    void on_actZoomReset_triggered();
+
+private:
+    Ui::MainWindow *ui;
+};
+
+#endif // MAINWINDOW_H

+ 1128 - 0
mainwindow.ui

@@ -0,0 +1,1128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>794</width>
+    <height>522</height>
+   </rect>
+  </property>
+  <property name="font">
+   <font>
+    <family>宋体</family>
+    <pointsize>10</pointsize>
+   </font>
+  </property>
+  <property name="windowTitle">
+   <string>QChart绘图详细功能</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <layout class="QHBoxLayout" name="horizontalLayout">
+    <property name="spacing">
+     <number>5</number>
+    </property>
+    <property name="leftMargin">
+     <number>5</number>
+    </property>
+    <property name="topMargin">
+     <number>5</number>
+    </property>
+    <property name="rightMargin">
+     <number>5</number>
+    </property>
+    <property name="bottomMargin">
+     <number>5</number>
+    </property>
+    <item>
+     <widget class="QSplitter" name="splitter">
+      <property name="orientation">
+       <enum>Qt::Horizontal</enum>
+      </property>
+      <widget class="QToolBox" name="toolBox">
+       <property name="minimumSize">
+        <size>
+         <width>260</width>
+         <height>0</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>400</width>
+         <height>16777215</height>
+        </size>
+       </property>
+       <property name="frameShape">
+        <enum>QFrame::NoFrame</enum>
+       </property>
+       <property name="currentIndex">
+        <number>0</number>
+       </property>
+       <widget class="QWidget" name="page">
+        <property name="geometry">
+         <rect>
+          <x>0</x>
+          <y>0</y>
+          <width>385</width>
+          <height>383</height>
+         </rect>
+        </property>
+        <attribute name="icon">
+         <iconset resource="res.qrc">
+          <normaloff>:/images/images/3.ico</normaloff>:/images/images/3.ico</iconset>
+        </attribute>
+        <attribute name="label">
+         <string>图表设置</string>
+        </attribute>
+        <layout class="QVBoxLayout" name="verticalLayout_5">
+         <property name="spacing">
+          <number>3</number>
+         </property>
+         <property name="leftMargin">
+          <number>3</number>
+         </property>
+         <property name="topMargin">
+          <number>3</number>
+         </property>
+         <property name="rightMargin">
+          <number>3</number>
+         </property>
+         <property name="bottomMargin">
+          <number>3</number>
+         </property>
+         <item>
+          <widget class="QScrollArea" name="scrollArea_2">
+           <property name="widgetResizable">
+            <bool>true</bool>
+           </property>
+           <widget class="QWidget" name="scrollAreaWidgetContents_2">
+            <property name="geometry">
+             <rect>
+              <x>0</x>
+              <y>-64</y>
+              <width>363</width>
+              <height>532</height>
+             </rect>
+            </property>
+            <layout class="QVBoxLayout" name="verticalLayout_4">
+             <item>
+              <widget class="QGroupBox" name="groupBox">
+               <property name="title">
+                <string>标题</string>
+               </property>
+               <layout class="QGridLayout" name="gridLayout_2">
+                <item row="0" column="0">
+                 <widget class="QLineEdit" name="editTitle"/>
+                </item>
+                <item row="0" column="1">
+                 <widget class="QPushButton" name="btnSetTitle">
+                  <property name="toolTip">
+                   <string>设置标题文字</string>
+                  </property>
+                  <property name="text">
+                   <string>设置</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="0" colspan="2">
+                 <widget class="QPushButton" name="btnSetTitleFont">
+                  <property name="text">
+                   <string>设置标题字体</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+             <item>
+              <widget class="QGroupBox" name="groupBox_4">
+               <property name="title">
+                <string>图例</string>
+               </property>
+               <layout class="QGridLayout" name="gridLayout_9">
+                <item row="0" column="0">
+                 <widget class="QRadioButton" name="radioButton">
+                  <property name="text">
+                   <string>上方</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item row="0" column="1">
+                 <widget class="QRadioButton" name="radioButton_2">
+                  <property name="text">
+                   <string>下方</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="0">
+                 <widget class="QRadioButton" name="radioButton_3">
+                  <property name="text">
+                   <string>左侧</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="1">
+                 <widget class="QRadioButton" name="radioButton_4">
+                  <property name="text">
+                   <string>右侧</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="2" column="0">
+                 <widget class="QCheckBox" name="chkLegendVisible">
+                  <property name="text">
+                   <string>图例可见</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item row="2" column="1">
+                 <widget class="QCheckBox" name="chkBoxLegendBackground">
+                  <property name="text">
+                   <string>背景可见</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="3" column="0">
+                 <widget class="QPushButton" name="btnLegendFont">
+                  <property name="text">
+                   <string>字体</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="3" column="1">
+                 <widget class="QPushButton" name="btnLegendlabelColor">
+                  <property name="text">
+                   <string>标签颜色</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+             <item>
+              <widget class="QGroupBox" name="groupBox_2">
+               <property name="title">
+                <string>边距</string>
+               </property>
+               <layout class="QGridLayout" name="gridLayout">
+                <item row="0" column="0">
+                 <widget class="QLabel" name="label">
+                  <property name="text">
+                   <string>左边距</string>
+                  </property>
+                  <property name="alignment">
+                   <set>Qt::AlignCenter</set>
+                  </property>
+                 </widget>
+                </item>
+                <item row="0" column="1">
+                 <widget class="QSpinBox" name="spinMarginLeft">
+                  <property name="minimum">
+                   <number>10</number>
+                  </property>
+                  <property name="maximum">
+                   <number>500</number>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="0">
+                 <widget class="QLabel" name="label_2">
+                  <property name="text">
+                   <string>右边距</string>
+                  </property>
+                  <property name="alignment">
+                   <set>Qt::AlignCenter</set>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="1">
+                 <widget class="QSpinBox" name="spinMarginRight">
+                  <property name="minimum">
+                   <number>10</number>
+                  </property>
+                  <property name="maximum">
+                   <number>500</number>
+                  </property>
+                 </widget>
+                </item>
+                <item row="2" column="0">
+                 <widget class="QLabel" name="label_3">
+                  <property name="text">
+                   <string>上边距</string>
+                  </property>
+                  <property name="alignment">
+                   <set>Qt::AlignCenter</set>
+                  </property>
+                 </widget>
+                </item>
+                <item row="2" column="1">
+                 <widget class="QSpinBox" name="spinMarginTop">
+                  <property name="minimum">
+                   <number>10</number>
+                  </property>
+                  <property name="maximum">
+                   <number>500</number>
+                  </property>
+                 </widget>
+                </item>
+                <item row="3" column="0">
+                 <widget class="QLabel" name="label_4">
+                  <property name="text">
+                   <string>下边距</string>
+                  </property>
+                  <property name="alignment">
+                   <set>Qt::AlignCenter</set>
+                  </property>
+                 </widget>
+                </item>
+                <item row="3" column="1">
+                 <widget class="QSpinBox" name="spinMarginBottom">
+                  <property name="minimum">
+                   <number>10</number>
+                  </property>
+                  <property name="maximum">
+                   <number>500</number>
+                  </property>
+                 </widget>
+                </item>
+                <item row="4" column="0" colspan="2">
+                 <widget class="QPushButton" name="btnSetMargin">
+                  <property name="text">
+                   <string>设置边距</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+             <item>
+              <widget class="QGroupBox" name="groupBox_15">
+               <property name="title">
+                <string>动画效果</string>
+               </property>
+               <layout class="QGridLayout" name="gridLayout_10">
+                <item row="0" column="0">
+                 <widget class="QLabel" name="label_6">
+                  <property name="text">
+                   <string>动画效果</string>
+                  </property>
+                  <property name="alignment">
+                   <set>Qt::AlignCenter</set>
+                  </property>
+                 </widget>
+                </item>
+                <item row="0" column="1">
+                 <widget class="QComboBox" name="cBoxAnimation">
+                  <item>
+                   <property name="text">
+                    <string>NoAnimation</string>
+                   </property>
+                  </item>
+                  <item>
+                   <property name="text">
+                    <string>GridAxisAnimations</string>
+                   </property>
+                  </item>
+                  <item>
+                   <property name="text">
+                    <string>SeriesAnimations</string>
+                   </property>
+                  </item>
+                  <item>
+                   <property name="text">
+                    <string>AllAnimations</string>
+                   </property>
+                  </item>
+                 </widget>
+                </item>
+                <item row="1" column="0">
+                 <widget class="QLabel" name="label_8">
+                  <property name="text">
+                   <string>主  题</string>
+                  </property>
+                  <property name="alignment">
+                   <set>Qt::AlignCenter</set>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="1">
+                 <widget class="QComboBox" name="cBoxTheme">
+                  <item>
+                   <property name="text">
+                    <string>Light</string>
+                   </property>
+                  </item>
+                  <item>
+                   <property name="text">
+                    <string>BlueCerulean</string>
+                   </property>
+                  </item>
+                  <item>
+                   <property name="text">
+                    <string>Dark</string>
+                   </property>
+                  </item>
+                  <item>
+                   <property name="text">
+                    <string>BrownSand</string>
+                   </property>
+                  </item>
+                  <item>
+                   <property name="text">
+                    <string>BlueNcs</string>
+                   </property>
+                  </item>
+                  <item>
+                   <property name="text">
+                    <string>HighContrast</string>
+                   </property>
+                  </item>
+                  <item>
+                   <property name="text">
+                    <string>BlueIcy</string>
+                   </property>
+                  </item>
+                  <item>
+                   <property name="text">
+                    <string>Qt</string>
+                   </property>
+                  </item>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+            </layout>
+           </widget>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+       <widget class="QWidget" name="page_2">
+        <property name="geometry">
+         <rect>
+          <x>0</x>
+          <y>0</y>
+          <width>385</width>
+          <height>383</height>
+         </rect>
+        </property>
+        <attribute name="icon">
+         <iconset resource="res.qrc">
+          <normaloff>:/images/images/dis3.ico</normaloff>:/images/images/dis3.ico</iconset>
+        </attribute>
+        <attribute name="label">
+         <string>曲线设置</string>
+        </attribute>
+        <layout class="QVBoxLayout" name="verticalLayout_10">
+         <property name="spacing">
+          <number>3</number>
+         </property>
+         <property name="leftMargin">
+          <number>3</number>
+         </property>
+         <property name="topMargin">
+          <number>3</number>
+         </property>
+         <property name="rightMargin">
+          <number>3</number>
+         </property>
+         <property name="bottomMargin">
+          <number>3</number>
+         </property>
+         <item>
+          <widget class="QScrollArea" name="scrollArea_3">
+           <property name="widgetResizable">
+            <bool>true</bool>
+           </property>
+           <widget class="QWidget" name="scrollAreaWidgetContents_3">
+            <property name="geometry">
+             <rect>
+              <x>0</x>
+              <y>0</y>
+              <width>363</width>
+              <height>431</height>
+             </rect>
+            </property>
+            <layout class="QVBoxLayout" name="verticalLayout_9">
+             <item>
+              <widget class="QGroupBox" name="groupBox_12">
+               <property name="maximumSize">
+                <size>
+                 <width>16777215</width>
+                 <height>60</height>
+                </size>
+               </property>
+               <property name="title">
+                <string>选择操作序列</string>
+               </property>
+               <layout class="QHBoxLayout" name="horizontalLayout_3">
+                <item>
+                 <widget class="QRadioButton" name="radioSeries0">
+                  <property name="text">
+                   <string>Sin曲线</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <widget class="QRadioButton" name="radioSeries1">
+                  <property name="text">
+                   <string>Cos曲线</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+             <item>
+              <widget class="QGroupBox" name="groupBox_13">
+               <property name="title">
+                <string>曲线外观</string>
+               </property>
+               <layout class="QGridLayout" name="gridLayout_3">
+                <item row="0" column="0">
+                 <widget class="QPushButton" name="btnSeriesName">
+                  <property name="text">
+                   <string>序列名称</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="0" column="1">
+                 <widget class="QLineEdit" name="editSeriesName">
+                  <property name="text">
+                   <string>Sin曲线</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="0">
+                 <widget class="QCheckBox" name="chkSeriesVisible">
+                  <property name="text">
+                   <string>序列可见</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="1">
+                 <widget class="QCheckBox" name="chkPointVisible">
+                  <property name="text">
+                   <string>数据点可见</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="2" column="0">
+                 <widget class="QPushButton" name="btnSeriesColor">
+                  <property name="text">
+                   <string>曲线颜色</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="2" column="1">
+                 <widget class="QPushButton" name="btnSeriesPen">
+                  <property name="text">
+                   <string>曲线Pen</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="3" column="0">
+                 <widget class="QLabel" name="label_5">
+                  <property name="text">
+                   <string>透明度</string>
+                  </property>
+                  <property name="alignment">
+                   <set>Qt::AlignCenter</set>
+                  </property>
+                 </widget>
+                </item>
+                <item row="3" column="1">
+                 <widget class="QSlider" name="sliderSeriesOpacity">
+                  <property name="maximum">
+                   <number>10</number>
+                  </property>
+                  <property name="pageStep">
+                   <number>2</number>
+                  </property>
+                  <property name="value">
+                   <number>10</number>
+                  </property>
+                  <property name="orientation">
+                   <enum>Qt::Horizontal</enum>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+             <item>
+              <widget class="QGroupBox" name="groupBox_3">
+               <property name="title">
+                <string>数据点标签</string>
+               </property>
+               <layout class="QVBoxLayout" name="verticalLayout_7">
+                <item>
+                 <widget class="QCheckBox" name="chkPointLabelVisible">
+                  <property name="text">
+                   <string>数据点标签可见</string>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <widget class="QPushButton" name="btnSeriesLabColor">
+                  <property name="text">
+                   <string>标签颜色</string>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <widget class="QPushButton" name="btnSeriesLabFont">
+                  <property name="text">
+                   <string>标签字体</string>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <widget class="QGroupBox" name="groupBox_14">
+                  <property name="title">
+                   <string>标签格式</string>
+                  </property>
+                  <layout class="QVBoxLayout" name="verticalLayout_6">
+                   <item>
+                    <widget class="QRadioButton" name="radioSeriesLabFormat0">
+                     <property name="text">
+                      <string>@yPoint</string>
+                     </property>
+                     <property name="checked">
+                      <bool>true</bool>
+                     </property>
+                    </widget>
+                   </item>
+                   <item>
+                    <widget class="QRadioButton" name="radioSeriesLabFormat1">
+                     <property name="text">
+                      <string>(@xPoint, @yPoint)</string>
+                     </property>
+                    </widget>
+                   </item>
+                  </layout>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+            </layout>
+           </widget>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+       <widget class="QWidget" name="page_3">
+        <property name="geometry">
+         <rect>
+          <x>0</x>
+          <y>0</y>
+          <width>385</width>
+          <height>383</height>
+         </rect>
+        </property>
+        <attribute name="icon">
+         <iconset resource="res.qrc">
+          <normaloff>:/images/images/39.ico</normaloff>:/images/images/39.ico</iconset>
+        </attribute>
+        <attribute name="label">
+         <string>坐标轴设置</string>
+        </attribute>
+        <layout class="QVBoxLayout" name="verticalLayout_3">
+         <property name="spacing">
+          <number>3</number>
+         </property>
+         <property name="leftMargin">
+          <number>3</number>
+         </property>
+         <property name="topMargin">
+          <number>3</number>
+         </property>
+         <property name="rightMargin">
+          <number>3</number>
+         </property>
+         <property name="bottomMargin">
+          <number>3</number>
+         </property>
+         <item>
+          <widget class="QScrollArea" name="scrollArea">
+           <property name="verticalScrollBarPolicy">
+            <enum>Qt::ScrollBarAsNeeded</enum>
+           </property>
+           <property name="widgetResizable">
+            <bool>true</bool>
+           </property>
+           <widget class="QWidget" name="scrollAreaWidgetContents">
+            <property name="geometry">
+             <rect>
+              <x>0</x>
+              <y>-459</y>
+              <width>363</width>
+              <height>834</height>
+             </rect>
+            </property>
+            <layout class="QVBoxLayout" name="verticalLayout_2">
+             <property name="spacing">
+              <number>3</number>
+             </property>
+             <property name="leftMargin">
+              <number>3</number>
+             </property>
+             <property name="topMargin">
+              <number>3</number>
+             </property>
+             <property name="rightMargin">
+              <number>3</number>
+             </property>
+             <property name="bottomMargin">
+              <number>3</number>
+             </property>
+             <item>
+              <widget class="QGroupBox" name="groupBox_7">
+               <property name="title">
+                <string>设置坐标轴对象</string>
+               </property>
+               <layout class="QHBoxLayout" name="horizontalLayout_2">
+                <item>
+                 <widget class="QRadioButton" name="radioX">
+                  <property name="text">
+                   <string>X轴</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <widget class="QRadioButton" name="radioY">
+                  <property name="text">
+                   <string>Y轴</string>
+                  </property>
+                  <property name="checked">
+                   <bool>false</bool>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+             <item>
+              <widget class="QGroupBox" name="groupBox_8">
+               <property name="title">
+                <string>坐标轴总体</string>
+               </property>
+               <layout class="QGridLayout" name="gridLayout_4">
+                <item row="0" column="0">
+                 <widget class="QLabel" name="label_7">
+                  <property name="text">
+                   <string>最小值</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="0" column="1">
+                 <widget class="QDoubleSpinBox" name="spinAxisMin">
+                  <property name="minimum">
+                   <double>-1000.000000000000000</double>
+                  </property>
+                  <property name="maximum">
+                   <double>1000.000000000000000</double>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="0">
+                 <widget class="QLabel" name="label_11">
+                  <property name="text">
+                   <string>最大值</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="1">
+                 <widget class="QDoubleSpinBox" name="spinAxisMax">
+                  <property name="minimum">
+                   <double>-1000.000000000000000</double>
+                  </property>
+                  <property name="maximum">
+                   <double>1000.000000000000000</double>
+                  </property>
+                  <property name="value">
+                   <double>10.000000000000000</double>
+                  </property>
+                 </widget>
+                </item>
+                <item row="2" column="0" colspan="2">
+                 <widget class="QCheckBox" name="chkBoxVisible">
+                  <property name="text">
+                   <string>isVisible</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item row="3" column="0" colspan="2">
+                 <widget class="QPushButton" name="btnSetAxisRange">
+                  <property name="text">
+                   <string>设置坐标范围</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+             <item>
+              <widget class="QGroupBox" name="groupBox_6">
+               <property name="title">
+                <string>轴标题</string>
+               </property>
+               <layout class="QGridLayout" name="gridLayout_6">
+                <item row="0" column="1" colspan="2">
+                 <widget class="QLineEdit" name="editAxisTitle">
+                  <property name="text">
+                   <string>time(secs)</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="2">
+                 <widget class="QPushButton" name="btnAxisSetTitleFont">
+                  <property name="text">
+                   <string>设置字体</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="0" column="0">
+                 <widget class="QPushButton" name="btnAxisSetTitle">
+                  <property name="text">
+                   <string>设置标题</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="0" colspan="2">
+                 <widget class="QCheckBox" name="chkBoxAxisTitle">
+                  <property name="text">
+                   <string>isTitleVisible</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+             <item>
+              <widget class="QGroupBox" name="groupBox_10">
+               <property name="title">
+                <string>轴刻度标签</string>
+               </property>
+               <layout class="QGridLayout" name="gridLayout_7">
+                <item row="0" column="0">
+                 <widget class="QPushButton" name="pushButton">
+                  <property name="text">
+                   <string>标签格式</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="0" column="1">
+                 <widget class="QLineEdit" name="editAxisLabelFormat">
+                  <property name="text">
+                   <string>%.1f</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="0">
+                 <widget class="QPushButton" name="btnAxisLabelColor">
+                  <property name="text">
+                   <string>文字颜色</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="1">
+                 <widget class="QPushButton" name="btnAxisLabelFont">
+                  <property name="text">
+                   <string>设置字体</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="2" column="0" colspan="2">
+                 <widget class="QCheckBox" name="chkBoxLabelsVisible">
+                  <property name="text">
+                   <string>labelsVisible</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+             <item>
+              <widget class="QGroupBox" name="groupBox_11">
+               <property name="title">
+                <string>GridLine</string>
+               </property>
+               <layout class="QVBoxLayout" name="verticalLayout">
+                <item>
+                 <widget class="QCheckBox" name="chkGridLineVisible">
+                  <property name="text">
+                   <string>isGridLineVisible</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <widget class="QPushButton" name="btnGridLineColor">
+                  <property name="text">
+                   <string>gridLineColor</string>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <widget class="QPushButton" name="pushButton_10">
+                  <property name="text">
+                   <string>gridLinePen</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+             <item>
+              <widget class="QGroupBox" name="groupBox_9">
+               <property name="title">
+                <string>Axis and Ticks</string>
+               </property>
+               <layout class="QGridLayout" name="gridLayout_5">
+                <item row="3" column="0" colspan="2">
+                 <widget class="QPushButton" name="btnAxisLinePenColor">
+                  <property name="text">
+                   <string>linePenColor</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="0" column="1">
+                 <widget class="QSpinBox" name="spinTickCount">
+                  <property name="minimum">
+                   <number>1</number>
+                  </property>
+                  <property name="maximum">
+                   <number>1000</number>
+                  </property>
+                  <property name="value">
+                   <number>10</number>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="0" colspan="2">
+                 <widget class="QCheckBox" name="chkAxisLineVisible">
+                  <property name="text">
+                   <string>isLineVisible</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
+                <item row="0" column="0">
+                 <widget class="QLabel" name="label_9">
+                  <property name="text">
+                   <string>Tick个数</string>
+                  </property>
+                  <property name="alignment">
+                   <set>Qt::AlignCenter</set>
+                  </property>
+                 </widget>
+                </item>
+                <item row="2" column="0" colspan="2">
+                 <widget class="QPushButton" name="btnAxisLinePen">
+                  <property name="text">
+                   <string>linePen</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+             <item>
+              <widget class="QGroupBox" name="groupBox_5">
+               <property name="title">
+                <string>MinorTick</string>
+               </property>
+               <layout class="QGridLayout" name="gridLayout_8">
+                <item row="0" column="0">
+                 <widget class="QLabel" name="label_10">
+                  <property name="text">
+                   <string>MinorTick个数</string>
+                  </property>
+                  <property name="alignment">
+                   <set>Qt::AlignCenter</set>
+                  </property>
+                 </widget>
+                </item>
+                <item row="0" column="1">
+                 <widget class="QSpinBox" name="spinMinorTickCount">
+                  <property name="value">
+                   <number>4</number>
+                  </property>
+                 </widget>
+                </item>
+                <item row="1" column="0" colspan="2">
+                 <widget class="QCheckBox" name="chkMinorTickVisible">
+                  <property name="text">
+                   <string>isMinorGridLineVisible</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="2" column="0" colspan="2">
+                 <widget class="QPushButton" name="btnMinorColor">
+                  <property name="text">
+                   <string>minorGridLineColor</string>
+                  </property>
+                 </widget>
+                </item>
+                <item row="3" column="0" colspan="2">
+                 <widget class="QPushButton" name="btnMinorPen">
+                  <property name="text">
+                   <string>minorGridLinePen</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
+            </layout>
+           </widget>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+      </widget>
+      <widget class="QChartView" name="chartView"/>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QToolBar" name="mainToolBar">
+   <property name="toolButtonStyle">
+    <enum>Qt::ToolButtonTextBesideIcon</enum>
+   </property>
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+   <addaction name="actDraw"/>
+   <addaction name="actZoomIn"/>
+   <addaction name="actZoomOut"/>
+   <addaction name="actZoomReset"/>
+   <addaction name="actQuit"/>
+  </widget>
+  <action name="actDraw">
+   <property name="icon">
+    <iconset resource="res.qrc">
+     <normaloff>:/images/images/828.bmp</normaloff>:/images/images/828.bmp</iconset>
+   </property>
+   <property name="text">
+    <string>刷新绘图</string>
+   </property>
+   <property name="toolTip">
+    <string>刷新绘图</string>
+   </property>
+  </action>
+  <action name="actQuit">
+   <property name="icon">
+    <iconset resource="res.qrc">
+     <normaloff>:/images/images/132.bmp</normaloff>:/images/images/132.bmp</iconset>
+   </property>
+   <property name="text">
+    <string>退出</string>
+   </property>
+   <property name="toolTip">
+    <string>退出</string>
+   </property>
+  </action>
+  <action name="actZoomIn">
+   <property name="icon">
+    <iconset resource="res.qrc">
+     <normaloff>:/images/images/418.bmp</normaloff>:/images/images/418.bmp</iconset>
+   </property>
+   <property name="text">
+    <string>放大</string>
+   </property>
+   <property name="toolTip">
+    <string>放大</string>
+   </property>
+  </action>
+  <action name="actZoomOut">
+   <property name="icon">
+    <iconset resource="res.qrc">
+     <normaloff>:/images/images/416.bmp</normaloff>:/images/images/416.bmp</iconset>
+   </property>
+   <property name="text">
+    <string>缩小</string>
+   </property>
+   <property name="toolTip">
+    <string>缩小</string>
+   </property>
+  </action>
+  <action name="actZoomReset">
+   <property name="icon">
+    <iconset resource="res.qrc">
+     <normaloff>:/images/images/414.bmp</normaloff>:/images/images/414.bmp</iconset>
+   </property>
+   <property name="text">
+    <string>原始大小</string>
+   </property>
+   <property name="toolTip">
+    <string>还原为原始大小</string>
+   </property>
+  </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+  <customwidget>
+   <class>QChartView</class>
+   <extends>QGraphicsView</extends>
+   <header location="global">qchartview.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources>
+  <include location="res.qrc"/>
+ </resources>
+ <connections>
+  <connection>
+   <sender>actQuit</sender>
+   <signal>triggered()</signal>
+   <receiver>MainWindow</receiver>
+   <slot>close()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>389</x>
+     <y>242</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

+ 92 - 0
qwdialogpen.cpp

@@ -0,0 +1,92 @@
+#include "qwdialogpen.h"
+#include "ui_qwdialogpen.h"
+
+#include    <QColorDialog>
+
+// 若MSVC 编译版本错误,修改 msvc-version.conf 文件
+// 解决MSVC编译时,界面汉字乱码的问题
+#if _MSC_VER >= 1600     //MSVC2015>1899,    MSVC_VER= 14.0
+#pragma execution_character_set("utf-8")
+#endif
+
+
+QWDialogPen::QWDialogPen(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::QWDialogPen)
+{
+    ui->setupUi(this);
+
+//“线型”ComboBox的选择项设置
+    ui->comboPenStyle->clear();
+    ui->comboPenStyle->addItem("NoPen",0);
+    ui->comboPenStyle->addItem("SolidLine",1);
+    ui->comboPenStyle->addItem("DashLine",2);
+    ui->comboPenStyle->addItem("DotLine",3);
+    ui->comboPenStyle->addItem("DashDotLine",4);
+    ui->comboPenStyle->addItem("DashDotDotLine",5);
+    ui->comboPenStyle->addItem("CustomDashLine",6);
+
+    ui->comboPenStyle->setCurrentIndex(1);
+}
+
+QWDialogPen::~QWDialogPen()
+{
+    delete ui;
+}
+
+void QWDialogPen::setPen(QPen pen)
+{ //设置QPen,并刷新显示界面
+    m_pen=pen;
+
+    ui->spinWidth->setValue(pen.width()); //线宽
+    int i=static_cast<int>(pen.style());  //枚举类型转换为整型
+    ui->comboPenStyle->setCurrentIndex(i);
+
+    QColor  color=pen.color();
+    ui->btnColor->setAutoFillBackground(true); //设置颜色按钮的背景色
+    QString str=QString::asprintf("background-color: rgb(%d, %d, %d);",
+                                  color.red(),color.green(),color.blue());
+    ui->btnColor->setStyleSheet(str);
+}
+
+QPen QWDialogPen::getPen()
+{//获得设置的属性
+    m_pen.setStyle(Qt::PenStyle(ui->comboPenStyle->currentIndex())); //线型
+    m_pen.setWidth(ui->spinWidth->value()); //线宽
+
+    QColor  color;
+    color=ui->btnColor->palette().color(QPalette::Button);
+    m_pen.setColor(color); //颜色
+    return  m_pen;
+}
+
+QPen QWDialogPen::getPen(QPen iniPen,bool &ok)
+{ //静态函数,获取QPen
+    QWDialogPen *Dlg=new QWDialogPen; //创建一个对话框
+    Dlg->setPen(iniPen); //设置初始化QPen
+
+    QPen    pen;
+    int ret=Dlg->exec(); //弹出对话框
+    if (ret==QDialog::Accepted)
+    {
+        pen=Dlg->getPen(); //获取
+        ok=true;    }
+    else
+    {
+        pen=iniPen;
+        ok=false;   }
+
+    delete  Dlg; //删除对话框对象
+    return  pen; //返回设置的QPen对象
+}
+
+void QWDialogPen::on_btnColor_clicked()
+{//设置颜色
+    QColor  color=QColorDialog::getColor();
+    if (color.isValid())
+    { //用样式表设置QPushButton的背景色
+        QString str=QString::asprintf("background-color: rgb(%d, %d, %d);",
+                                      color.red(),color.green(),color.blue());
+        ui->btnColor->setStyleSheet(str);
+    }
+}

+ 30 - 0
qwdialogpen.h

@@ -0,0 +1,30 @@
+#ifndef QWDIALOGPEN_H
+#define QWDIALOGPEN_H
+
+#include    <QDialog>
+#include    <QPen>
+
+namespace Ui {
+class QWDialogPen;
+}
+
+class QWDialogPen : public QDialog
+{ //QPen属性设置对话框
+    Q_OBJECT
+private:
+    QPen    m_pen; //成员变量
+public:
+    explicit QWDialogPen(QWidget *parent = 0);
+    ~QWDialogPen();
+
+    void    setPen(QPen pen); //设置QPen,用于对话框的界面显示
+    QPen    getPen(); //获取对话框设置的QPen的属性
+    static  QPen    getPen(QPen  iniPen, bool &ok);  //静态函数
+
+private slots:
+    void on_btnColor_clicked();
+private:
+    Ui::QWDialogPen *ui;
+};
+
+#endif // QWDIALOGPEN_H

+ 234 - 0
qwdialogpen.ui

@@ -0,0 +1,234 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QWDialogPen</class>
+ <widget class="QDialog" name="QWDialogPen">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>319</width>
+    <height>139</height>
+   </rect>
+  </property>
+  <property name="font">
+   <font>
+    <family>宋体</family>
+    <pointsize>10</pointsize>
+   </font>
+  </property>
+  <property name="windowTitle">
+   <string>QPen属性设置对话框</string>
+  </property>
+  <layout class="QHBoxLayout" name="horizontalLayout">
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Pen属性设置</string>
+     </property>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0">
+       <widget class="QLabel" name="label">
+        <property name="text">
+         <string>线 型</string>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="2">
+       <spacer name="horizontalSpacer_2">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>98</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="2" column="2">
+       <spacer name="horizontalSpacer">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>98</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="2" column="1">
+       <widget class="QSpinBox" name="spinWidth">
+        <property name="minimumSize">
+         <size>
+          <width>100</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="minimum">
+         <number>1</number>
+        </property>
+        <property name="maximum">
+         <number>100</number>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="0">
+       <widget class="QLabel" name="label_3">
+        <property name="text">
+         <string>颜 色</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="label_2">
+        <property name="text">
+         <string>线 宽</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" colspan="2">
+       <widget class="QComboBox" name="comboPenStyle"/>
+      </item>
+      <item row="1" column="1">
+       <spacer name="verticalSpacer">
+        <property name="orientation">
+         <enum>Qt::Vertical</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>20</width>
+          <height>40</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="3" column="1">
+       <spacer name="verticalSpacer_2">
+        <property name="orientation">
+         <enum>Qt::Vertical</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>20</width>
+          <height>40</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="4" column="1">
+       <widget class="QPushButton" name="btnColor">
+        <property name="autoFillBackground">
+         <bool>false</bool>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">background-color: rgb(255, 0, 255);</string>
+        </property>
+        <property name="text">
+         <string/>
+        </property>
+        <property name="flat">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <item>
+      <spacer name="verticalSpacer_5">
+       <property name="orientation">
+        <enum>Qt::Vertical</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>20</width>
+         <height>40</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="btnOK">
+       <property name="text">
+        <string>确 定</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="verticalSpacer_4">
+       <property name="orientation">
+        <enum>Qt::Vertical</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>20</width>
+         <height>40</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="btnCancel">
+       <property name="text">
+        <string>取 消</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="verticalSpacer_3">
+       <property name="orientation">
+        <enum>Qt::Vertical</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>20</width>
+         <height>40</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>btnOK</sender>
+   <signal>clicked()</signal>
+   <receiver>QWDialogPen</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>337</x>
+     <y>51</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>191</x>
+     <y>79</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>btnCancel</sender>
+   <signal>clicked()</signal>
+   <receiver>QWDialogPen</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>337</x>
+     <y>111</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>191</x>
+     <y>79</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

+ 13 - 0
res.qrc

@@ -0,0 +1,13 @@
+<RCC>
+    <qresource prefix="/images">
+        <file>images/132.bmp</file>
+        <file>images/828.bmp</file>
+        <file>images/dis3.ico</file>
+        <file>images/39.ico</file>
+        <file>images/3.ico</file>
+        <file>images/f14.ico</file>
+        <file>images/414.bmp</file>
+        <file>images/416.bmp</file>
+        <file>images/418.bmp</file>
+    </qresource>
+</RCC>

+ 28 - 0
samp9_2.pro

@@ -0,0 +1,28 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2016-12-23T00:04:20
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+QT       += charts
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = samp9_2
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+        mainwindow.cpp \
+    qwdialogpen.cpp
+
+HEADERS  += mainwindow.h \
+    qwdialogpen.h
+
+FORMS    += mainwindow.ui \
+    qwdialogpen.ui
+
+RESOURCES += \
+    res.qrc