Qt OpenGL project[SOLVED]
-
Hello!
I decided to try an OpenGL technique in Qt. But from the first base step I have a small problem. What kind of project I need to create? Is it a common Qt Widget Project or is it GLSL?
Thank you for answers beforehand.
-
Yes, it is a common qt widget project. For doing this you have to create your own QGLWidget class, which heritates QGLWidget and declare the 3 virtual functions:
- void initializeGL();
- void paintGL();
- void resizeGL(int , int );
I am working an Qt OpenGL project right now. Here you have a class example from my program:
@class QOpenGL : public QGLWidget {
Q_OBJECT// OPENGL FUNCTIONS
void initializeGL();
void paintGL();
void resizeGL(int , int );
// MOUSE CONTROL FUNCTIONS
void mousePressEvent(QMouseEvent*);
void mouseReleaseEvent(QMouseEvent*);
void mouseMoveEvent(QMouseEvent*);public:
// CONSTRUCTOR
explicit QOpenGL(QWidget *parent = 0);
~QOpenGL() { doneCurrent(); }
};@
You can see in fact that the QGLWidget is a child class of QWidget. On my example I re-implemented the mouse functions (from QWidget) in order to have control on mouse input. You can see Qt Help for more info.Cheers!
-
I forgot, in your project file .pro you should also add the following line:
@QT += opengl@ -
Thank you for your answer!