包含头文件如下
#include <QOpenGLWidget>
#include <OpenGl_GraphicDriver.hxx>
#include <Standard.hxx>
#include <Xw_Window.hxx>
#include <Aspect_DisplayConnection.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <AIS_InteractiveContext.hxx>
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
会提示很多的错误,最终集中在
In file included from /usr/local/include/opencascade/OpenGl_GlCore11Fwd.hxx:19:0,
from /usr/local/include/opencascade/OpenGl_GlCore11.hxx:19,
from /usr/local/include/opencascade/OpenGl_Context.hxx:37,
from /usr/local/include/opencascade/OpenGl_GraphicDriver.hxx:44,
from ../tst_QGL1/mc.h:6,
from ../tst_QGL1/mc.cpp:1:
提示没有一个类型的名字
分析原因:一般头文件冲突就是没有包含和重复包含或者在不同的位置有相同的文件
但是头文件中都加了防止重复包含的宏,可能还是顺序问题
最终更改一下以下两个顺序,解决问题。
注意:之前也遇到过occ中头文件顺序导致的问题,具体什么错误忘了,occ使用要尤其注意头文件包含顺序。
#include <OpenGl_GraphicDriver.hxx> #include <QOpenGLWidget>#include