Fri, 08/21/2020 - 15:36
Forums:
I try to figure out how to implement a qt view for opencascade v3d_viewer.
qt5 ask for their header file should be call first. But if put #include <OpenGl_GraphicDriver.hxx> below #include <QGLWidget> , it will get error.
Finally, I end with this occview.h file:
#include <QGLWidget>
#include <QPaintEvent>
#include <QResizeEvent>
//Opencascade includes
#include <AIS_InteractiveContext.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
class OccView : public QGLWidget
{
.....
and this occview.cpp:
// QMouseEvent and QRubberBand should above OpenGl_GraphicDriver.hxx
#include <QMouseEvent>
#include <QRubberBand>
//OpenGl_GraphicDriver.hxx should above occview.h
#include <OpenGl_GraphicDriver.hxx>
#include "occview.h"
#include <Aspect_DisplayConnection.hxx>
#include <Xw_Window.hxx>
static Handle(Graphic3d_GraphicDriver)& GetGraphicDriver()
{
static Handle(Graphic3d_GraphicDriver) aGraphicDriver;
return aGraphicDriver;
}
OccView::OccView(QWidget *parent)
: QGLWidget(parent)
{
....
I passed the compiling. but I dont know why.
Anyone can give me some hint?
Attachments:
Fri, 08/21/2020 - 16:05
This is a common issue with windows.h and GL.h inclusion:
As consequence, including headers with and without such disabling macros makes result order-dependent (and some files really need these disabled declarations).
OCCT and Qt have own dedicated declarations of newer OpenGL staff, conflicting to each other and leading to various compilation errors when mixed (like QGLWidget.h and OpenGl_GraphicDriver.h).
So, the general advice is:
Split code into pieces so that each cpp includes only a single GL wrapper (use forward declarations in header files when possible).
Fri, 08/21/2020 - 16:32
Kirill Gavrilov, thanks for your fast answer.
It save me a lot of time.