Probably OpenGL is the only thing I can not use in Qt, Maya and 3Ds and another autodesk program pa uses opengl in qt, but no tutorial or example that works.
I have already created a class for the widget based on QOpenGLWidget (Since QGLWidget is obsolete), then in the Ui editor I add a widget and promote it to the class I created.
Result, when I compile a white screen without menus or anything with the frozen screen, then the crash application.
Several tutorials do this way and it works, but with me it always gives the same result, crash application.
They all work on video, less in practice.
glpanel.h code
#include <QtOpenGL>
class GLPanel : public QOpenGLWidget, protected QOpenGLFunctions{
Q_OBJECT
public:
explicit GLPanel(QWidget *parent = 0);
protected:
void initializeGL() Q_DECL_OVERRIDE;
void resizeGL(int w, int h) Q_DECL_OVERRIDE;
void paintGL() Q_DECL_OVERRIDE;
};
glpanel.cpp code
#include "glpanel.h"
GLPanel::GLPanel(QWidget *parent) :
QOpenGLWidget(parent)
{
}
void GLPanel::initializeGL()
{
initializeOpenGLFunctions();
}
void GLPanel::resizeGL(int w, int h)
{
}
void GLPanel::paintGL()
{
}
ui code
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Ives 3D</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="GLPanel" name="Viewport" native="true"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="action_Exit"/>
</widget>
<addaction name="menuFile"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<action name="action_Exit">
<property name="text">
<string>&Exit</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>GLPanel</class>
<extends>QWidget</extends>
<header>glpanel.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Can someone give me a light? !!