QT使用python时出现: error: expected unqualified-id before “;” token

在使用QT Creator构建C++项目时,因为要使用Python脚本,所以要调用Python.h文件

在使用时发现会出现错误

H:\Python\Python37\include\object.h:448: error: expected unqualified-id before ';' token
     PyType_Slot *slots; /* terminated by slot==0. */
 QT使用python时出现: error: expected unqualified-id before “;” token

出现这个问题和项目本身无关 因为错误的文件在Python的include\object.h

QT使用python时出现: error: expected unqualified-id before “;” token

 应该是头文件使用出现问题

解决

后经过尝试发现#include <Python.h>要放在#include <QMainWindow>的前面,头文件的顺序不正确也会报错。