QtCharts compilation (compilation environment MSVC12) and VS2013 configuration QtCharts

introduce

Recently, Qt has open-sourced the QtCharts graphical widget. Now we can compile and configure our own development environment, and use QtCharts to design various histograms and discounted charts for free. There are some examples compiled for MinGW+QtCreator on the Internet and finally used in QtCreator. For Qt+VS users, there is still relatively little information on how to compile MSVC+QTCharts and configure QtCharts. Therefore, after asking a netizen for advice, the author decided to write this blog post as a record.
Write picture description here

Download QtCharts source code and Perl compiler

QtCharts download address (GitHub): https://github.com/qtproject/qtcharts
I provide the downloaded QtChart and Perl compiler: http://pan.baidu.com/s/1qXe10KW
Note: Before compiling QtCharts, you need to first Install Perl and configure it well, otherwise there will be an error when compiling QtCharts! QtCreator is also required.
Write picture description here

Perl installation

You can choose the default path to install Perl, or you can specify the path you need. How to install and configure, Baidu experience is very detailed, please check the link below: http://jingyan.baidu.com/article/9f7e7ec0b798ae6f281554e9.html?st=2&os=0&bd_page_type=1&net_type=1
Note: After configuring the environment variables, you need to log out or reboot the system.

Compile QtCharts

  1. Unzip QtCharts, and open the qtcharts.pro file with QtCreator.
    Write picture description here
  2. build project
    Write picture description here
  3. deployment project
    Write picture description here
    Write picture description here
  4. deployment complete
    Write picture description here
    Write picture description here
    Write picture description here

Install QtCharts help documentation

  1. Make parameter input: docs, then redeploy the project.
    Write picture description here
  2. Copy the files in the directory E:\CPlusPlusLib\build-qtcharts-unknown-Release\doc to the directory: C:\Qt\Qt5.5.1\Docs\Qt-5.5.
    Write picture description here
    Write picture description here
  3. Restart QtCreator and search for QtCharts in the help.
    Write picture description here

Install QtCharts Eamples

  1. Copy the charts file in the source code directory: E:\CPlusPlusLib\qtcharts\examples to the Qt library directory C:\Qt\Qt5.5.1\Examples\Qt-5.5.
    Write picture description here
    Write picture description here
  2. Modify the examples.pro file in the Qt\Qt5.5.1\Examples\Qt-5.5 folder.
    Write picture description here
  3. Restart QtCreator, enter charts in the example, and view the example.
    Write picture description here

Configure QtCharts in VS2013

  1. Open VS2013 to create a new Qt project.
    Write picture description here
  2. Create a new QtChart property sheet, and modify the VC++ directory and additional dependencies as follows
    Write picture description here
    Write picture description here
  3. Add the following code in the source file testqtcharts.cpp
    QLineSeries *series = new QLineSeries();

    series->append(0, 6);
    series->append(2, 4);
    series->append(3, 8);
    series->append(7, 4);
    series->append(10, 5);
    *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);

    QChart *chart = new QChart();
    chart->legend()->hide();
    chart->addSeries(series);
    chart->createDefaultAxes();
    chart->setTitle("Simple line chart example");

    QChartView *chartView = new QChartView(chart);
    chartView->setRenderHint(QPainter::Antialiasing);

    setCentralWidget(chartView);
  1. Compile and run the results
    Write picture description here

Program engineering (code + UI file + property sheet) sharing

Baidu cloud download link: http://pan.baidu.com/s/1sk8l38D

Supongo que te gusta

Origin blog.csdn.net/wokaowokaowokao12345/article/details/50933447#comments_25853707
Recomendado
Clasificación