C++ drawing (import matplotlibcpp.h header file)

QT+C++ import matplotlibcpp for drawing

Preparations:
1. Download python and QT
2. Configure the environment to ensure that QT+c++ and python can run normally
Steps:
1. First import the Python.h header file in QT, see this link for detailed steps: https://blog .csdn.net/weixin_45866980/article/details/130240898?ydreferer=aHR0cHM6Ly9tcC5jc2RuLm5ldC8%3D
2. Install the matplotlib package for your own python, and use pip to install the
installation steps: 1. Press and hold the "Start" key and the "R" key, Enter "cmd" in the pop-up window to bring up the command window
insert image description here

Enter the following statement:

pip install matplotlib

Enter the following code in QT to see if an error is reported to determine whether the import is successful:

#define WITHOUT_NUMPY  // 如果没有安装 NumPy,可以定义 WITHOUT_NUMPY
#include "matplotlibcpp.h"

If the error is reported and matplotlibcpp is not found, it may be that you do not have this package yet, and you need to download it again. The download link is as follows:
https://github.com/lava/matplotlib-cpp.git
If you can’t browse the page, you can see this link to install the accelerator Enter github: https://blog.csdn.net/weixin_45866980/article/details/126205711?spm=1001.2014.3001.5502
If you still get an error after downloading normally, just copy the matplotlibcpp.cpp file directly to the python environment you installed Include, then it can be used normally.
insert image description here
**Note: **Because the previous failure to install pypy caused the computer environment to be messy, I went through some tutorials on the Internet and failed to import matplotlibcpp normally. The simple and rude method of directly copying and pasting succeeded instead, so record it here, but this method is not Must be for everyone, use with caution

Guess you like

Origin blog.csdn.net/weixin_45866980/article/details/130620644