qopenglwidget doesn't fire
-
can't start qopenglwidget. I tried to call but for some reason the error jumps out.
i have qt 5.11 i can't use qt 3D and Quick 3Dhere is the code
dialogokno.h
#ifndef DIALOGOKNO_H #define DIALOGOKNO_H #include <QMainWindow> #include <QFile> #include <QPushButton> #include <QLabel> #include <QSize> #include <QApplication> #include <QDesktopWidget> #include <QRect> #include <QDebug> #include <QLineEdit> #include <QGridLayout> #include <QSpacerItem> #include <QObject> #include "qopenglwidget.h" class DialogOkno : public QWidget { Q_OBJECT public: DialogOkno(QWidget *parent = 0); ~DialogOkno(); protected: QFile* file; // загрузить файл QGridLayout* gl_layaout[4]; QPushButton* b_load; // кнопка для выбора и загрузки файла QLabel* l_label[3]; QLineEdit* le_edit[7]; QSpacerItem* si_spacer[4]; QOpenGLWidget *openGLWidget; //опен гл void initializeGL(); void paintGL(); void resizeGL(int width, int height); }; #endif // DIALOGOKNO_H
dialogokno.cpp
#include "dialogokno.h" DialogOkno::DialogOkno(QWidget *parent) : QWidget(parent) { // обявл элементы gl_layaout[0] = new QGridLayout(parent); gl_layaout[1] = new QGridLayout(parent); gl_layaout[2] = new QGridLayout(parent); gl_layaout[3] = new QGridLayout(parent); openGLWidget = new QOpenGLWidget(parent); l_label[0] = new QLabel(parent); l_label[1] = new QLabel(parent); l_label[2] = new QLabel(parent); le_edit[0] = new QLineEdit(parent); le_edit[1] = new QLineEdit(parent); le_edit[2] = new QLineEdit(parent); le_edit[3] = new QLineEdit(parent); le_edit[4] = new QLineEdit(parent); le_edit[5] = new QLineEdit(parent); le_edit[6] = new QLineEdit(parent); // настройки элеметов (стилизация) // заполнение элементов l_label[0]->setText("hla_global"); l_label[1]->setText("hla_local"); l_label[2]->setText("logger"); le_edit[0]->setText("server_ip_global"); le_edit[1]->setText("server_port_global"); le_edit[2]->setText("server_port_local"); le_edit[3]->setText("server_port_local"); le_edit[4]->setText("log"); le_edit[5]->setText("log_period_ms"); le_edit[6]->setText("log_size_in_mb"); //разложение элементов по группам gl_layaout[0]->addWidget(l_label[0], 0, 0, 1, 1); gl_layaout[0]->addWidget(le_edit[0], 1, 0, 1, 1); gl_layaout[0]->addWidget(le_edit[1], 2, 0, 1, 1); gl_layaout[1]->addWidget(l_label[1], 0, 0, 1, 1); gl_layaout[1]->addWidget(le_edit[2], 1, 0, 1, 1); gl_layaout[1]->addWidget(le_edit[3], 2, 0, 1, 1); gl_layaout[2]->addWidget(l_label[2], 0, 0, 1, 1); gl_layaout[2]->addWidget(le_edit[4], 1, 0, 1, 1); gl_layaout[2]->addWidget(le_edit[5], 2, 0, 1, 1); gl_layaout[2]->addWidget(le_edit[6], 3, 0, 1, 1); gl_layaout[3]->addLayout(gl_layaout[0], 0, 0, 1, 1); si_spacer[0] = new QSpacerItem(120, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); gl_layaout[3]->addItem(si_spacer[0], 0, 1, 1, 1); gl_layaout[3]->addLayout(gl_layaout[1], 0, 2, 1, 1); si_spacer[1] = new QSpacerItem(120, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); gl_layaout[3]->addItem(si_spacer[1], 0, 3, 1, 1); si_spacer[2] = new QSpacerItem(20, 82, QSizePolicy::Minimum, QSizePolicy::Expanding); gl_layaout[3]->addItem(si_spacer[2],1, 0, 1, 1); gl_layaout[3]->addLayout(gl_layaout[2], 2, 0, 1, 1); si_spacer[3] = new QSpacerItem(20, 82, QSizePolicy::Minimum, QSizePolicy::Expanding); gl_layaout[3]->addItem(si_spacer[3],3,0); gl_layaout[3]->addWidget(openGLWidget, 1, 1, 3, 3); this->setLayout(gl_layaout[3]); } DialogOkno::~DialogOkno() { } void QOpenGLWidget::initializeGL() { glClearColor(1.0, 1.0, 1.0, 0.0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } void QOpenGLWidget::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glColor3f(0.0, 0.0, 0.0); glBegin(GL_QUADS); glVertex3f (0.51, 0.51, 0.51); glVertex3f (-0.51, 0.51, 0.51); glVertex3f (-0.51, -0.51, 0.51); glVertex3f (0.51, -0.51, 0.51); glEnd(); } void QOpenGLWidget::resizeGL(int width, int height) { glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); }
main.cpp
#include "dialogokno.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); DialogOkno w; QDesktopWidget desktop; QRect rect = desktop.availableGeometry(desktop.primaryScreen()); // прямоугольник с размерами экрана QPoint center = rect.center(); //координаты центра экрана qDebug() << "rect.x()/2 " <<rect.y()/2 << "rect.y()/2" << rect.y()/2; qDebug() << "center.x()/2 " <<center.y() << "center.y()/2" << center.y(); w.resize(center.x(), center.y()); w.setWindowTitle("программа"); w.show(); return a.exec(); }
dialog_okno_qmake.pro
#------------------------------------------------- # # Project created by QtCreator 2021-11-24T16:28:03 # #------------------------------------------------- QT += core gui opengl greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = dialog_okno_qmake TEMPLATE = app # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp \ dialogokno.cpp HEADERS += \ dialogokno.h INCLUDEPATH += $$PWD/glfw_bin/include/GLFW/ \ # добавляем для удобства чтоб напрямую писать $$PWD/glew_bin/include/GL/ \ # только название заголовчного файла без полного пути $$PWD/stb_image/ HEADERS += \ glfw_bin/include/GLFW/glfw3.h \ glfw_bin/include/GLFW/glfw3native.h \ glew_bin/include/GL/glew.h \ # --- linux --- unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lOpenGL INCLUDEPATH += $$PWD/../../../../usr/include/GL DEPENDPATH += $$PWD/../../../../usr/include/GL unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lGLEW INCLUDEPATH += $$PWD/../../../../usr/include/GL DEPENDPATH += $$PWD/../../../../usr/include/GL unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lglut INCLUDEPATH += $$PWD/../../../../usr/include/GL DEPENDPATH += $$PWD/../../../../usr/include/GL unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lGLU INCLUDEPATH += $$PWD/../../../../usr/include/GL DEPENDPATH += $$PWD/../../../../usr/include/GL
output :
Запускается /home/dima/dima_project/dialog_okno_qmake/dialog_okno_qmake... rect.x()/2 0 rect.y()/2 0 center.x()/2 515 center.y()/2 515 QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x59b7a92e99a0 composeAndFlush: makeCurrent() failed /home/dima/dima_project/dialog_okno_qmake/dialog_okno_qmake завершился с кодом 0
-
#include "dialogokno.h"
#include <QApplication>int main(int argc, char *argv[]) { QApplication a(argc, argv); QApplication::setAttribute(Qt::AA_ForceRasterWidgets, false); DialogOkno w; QDesktopWidget desktop; QRect rect = desktop.availableGeometry(desktop.primaryScreen()); // прямоугольник с размерами экрана QPoint center = rect.center(); //координаты центра экрана qDebug() << "rect.x()/2 " <<rect.y()/2 << "rect.y()/2" << rect.y()/2; qDebug() << "center.x()/2 " <<center.y() << "center.y()/2" << center.y(); w.resize(center.x(), center.y()); w.setWindowTitle("программа"); w.show(); return a.exec(); }
[
QApplication::setAttribute(Qt::AA_ForceRasterWidgets, false);
](link https://wiki.astralinux.ru/pages/viewpage.action?pageId=43614493) -
Your code does not even compile
For example this will not work
void QOpenGLWidget::paintGL()
Fix your code first and remove all non-needed stuff.
-
Besides fixing your code, you might also have set the default surface format in main.cpp. See the examples, for instance the 2D paint OpenGL example.
-
@Christian-Ehrlicher how ??
-
@mchinand I tried
rect.x()/2 0 rect.y()/2 0 center.x()/2 515 center.y()/2 515 QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed QOpenGLContext::makeCurrent() called with non-opengl surface 0x691e4a3d5ce0 composeAndFlush: makeCurrent() failed
-
#include "dialogokno.h"
#include <QApplication>int main(int argc, char *argv[]) { QApplication a(argc, argv); QApplication::setAttribute(Qt::AA_ForceRasterWidgets, false); DialogOkno w; QDesktopWidget desktop; QRect rect = desktop.availableGeometry(desktop.primaryScreen()); // прямоугольник с размерами экрана QPoint center = rect.center(); //координаты центра экрана qDebug() << "rect.x()/2 " <<rect.y()/2 << "rect.y()/2" << rect.y()/2; qDebug() << "center.x()/2 " <<center.y() << "center.y()/2" << center.y(); w.resize(center.x(), center.y()); w.setWindowTitle("программа"); w.show(); return a.exec(); }
[
QApplication::setAttribute(Qt::AA_ForceRasterWidgets, false);
](link https://wiki.astralinux.ru/pages/viewpage.action?pageId=43614493) -
Here's the main in the example project I linked to above. As I said above, add the surface format lines to your main.
#include "window.h" #include <QApplication> #include <QSurfaceFormat> int main(int argc, char *argv[]) { QApplication app(argc, argv); QSurfaceFormat fmt; fmt.setSamples(4); QSurfaceFormat::setDefaultFormat(fmt); Window window; window.show(); return app.exec(); }
-
@timob256 said in qopenglwidget doesn't fire:
@Christian-Ehrlicher how ??
You wrote the code, so you should be able to post a valid, compilable example - your code you posted above for sure does not compile at all...
-
@Christian-Ehrlicher said in qopenglwidget doesn't fire:
You wrote the code, so you should be able to post a valid, compilable example - your code you posted above for sure does not compile at all...
#ifndef MYGLWIDGET_H #define MYGLWIDGET_H #include <QOpenGLWidget> #include <QDebug> //#include <freeglut.h> #include <iostream> #include <sstream> #include <string> #include <fstream> #include <vector> class MyGLWidget : public QOpenGLWidget { Q_OBJECT public: MyGLWidget(QWidget* parent = nullptr); // Globals. std::vector<float> verticesVector; // Vector to read in vertex x, y and z values fromt the OBJ file. std::vector<int> facesVector; // Vector to read in face vertex indices from the OBJ file. float *vertices = NULL; // Vertex array of the object x, y, z values. int *faces = NULL; // Face (triangle) vertex indices. int numIndices; // Number of face vertex indices. float Xangle = 0.0, Yangle = 0.0, Zangle = 0.0; // Angles to rotate the object. void loadOBJ(std::string fileName); protected: void initializeGL(); void resizeGL(int w, int h); void paintGL(); }; #endif // MYGLWIDGET_H #include "myglwidget.h" MyGLWidget::MyGLWidget(QWidget * parent): QOpenGLWidget(parent) { } void MyGLWidget::initializeGL() { glEnableClientState(GL_VERTEX_ARRAY); glClearColor(1.0, 1.0, 1.0, 0.0); } void MyGLWidget::resizeGL(int w, int h) { // glViewport(0, 0, w, h); // glMatrixMode(GL_PROJECTION); // glLoadIdentity(); // glFrustum(-5.0, 5.0, -5.0, 5.0, 5.0, 100.0); // glMatrixMode(GL_MODELVIEW); glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); } void MyGLWidget::paintGL() { glClearColor(1.0, 1.0, 0.0, 0.0); // Read the external OBJ file into the internal vertex and face vectors. loadOBJ("gourd.obj"); qDebug() << "tyt1"; // Size the vertex array and copy into it x, y, z values from the vertex vector. vertices = new float[verticesVector.size()]; for (int i = 0; i < verticesVector.size(); i++) vertices[i] = verticesVector[i]; qDebug() << "tyt2"; // Size the faces array and copy into it face index values from the face vector. faces = new int[facesVector.size()]; for (int i = 0; i < facesVector.size(); i++) faces[i] = facesVector[i]; numIndices = facesVector.size(); glVertexPointer(3, GL_FLOAT, 0, vertices); qDebug() << "tyt3"; } void MyGLWidget::loadOBJ(std::string fileName) { std::string line; int count, vertexIndex1, vertexIndex2, vertexIndex3; float coordinateValue; char currentCharacter, previousCharacter; // Open the OBJ file. std::ifstream inFile(fileName.c_str(), std::ifstream::in); // Read successive lines. while (getline(inFile, line)) { // Line has vertex data. if (line.substr(0, 2) == "v ") { // Initialize a string from the character after "v " to the end. std::istringstream currentString(line.substr(2)); // Read x, y and z values. The (optional) w value is not read. for (count = 1; count <= 3; count++) { currentString >> coordinateValue; verticesVector.push_back(coordinateValue); } } // Line has face data. else if (line.substr(0, 2) == "f ") { // Initialize a string from the character after "f " to the end. std::istringstream currentString(line.substr(2)); // Strategy in the following to detect a vertex index within a face line is based on the // fact that vertex indices are exactly those that follow a white space. Texture and // normal indices are ignored. // Moreover, from the third vertex of a face on output one triangle per vertex, that // being the next triangle in a fan triangulation of the face about the first vertex. previousCharacter = ' '; count = 0; while (currentString.get(currentCharacter)) { // Stop processing line at comment. if ((previousCharacter == '#') || (currentCharacter == '#')) break; // Current character is the start of a vertex index. if ((previousCharacter == ' ') && (currentCharacter != ' ')) { // Move the string cursor back to just before the vertex index. currentString.unget(); // Read the first vertex index, decrement it so that the index range is from 0, increment vertex counter. if (count == 0) { currentString >> vertexIndex1; vertexIndex1--; count++; } // Read the second vertex index, decrement it, increment vertex counter. else if (count == 1) { currentString >> vertexIndex2; vertexIndex2--; count++; } // Read the third vertex index, decrement it, increment vertex counter AND output the first triangle. else if (count == 2) { currentString >> vertexIndex3; vertexIndex3--; count++; facesVector.push_back(vertexIndex1); facesVector.push_back(vertexIndex2); facesVector.push_back(vertexIndex3); } // From the fourth vertex and on output the next triangle of the fan. else { vertexIndex2 = vertexIndex3; currentString >> vertexIndex3; vertexIndex3--; facesVector.push_back(vertexIndex1); facesVector.push_back(vertexIndex2); facesVector.push_back(vertexIndex3); } // Begin the process of detecting the next vertex index just after the vertex index just read. currentString.get(previousCharacter); } // Current character is not the start of a vertex index. Move ahead one character. else previousCharacter = currentCharacter; } } // Nothing other than vertex and face data is processed. else { } } // Close the OBJ file. inFile.close(); qDebug() << "tyt0"; } #ifndef DIALOGOKNO_H #define DIALOGOKNO_H #include <QMainWindow> #include <QFile> #include <QPushButton> #include <QLabel> #include <QSize> #include <QApplication> #include <QDesktopWidget> #include <QRect> #include <QDebug> #include <QLineEdit> #include <QGridLayout> #include <QSpacerItem> #include <QObject> #include <QOpenGLWidget> #include "myglwidget.h" //#include "helper.h" //#include "glwidget.h" class DialogOkno : public QWidget { Q_OBJECT public: DialogOkno(QWidget *parent = 0); ~DialogOkno(); protected: // QWidget* centralWidget; QFile* file; // загрузить файл QGridLayout* gl_layaout[4]; QPushButton* b_load; // кнопка для выбора и загрузки файла QLabel* l_label[3]; QLineEdit* le_edit[7]; QSpacerItem* si_spacer[4]; }; #endif // DIALOGOKNO_H #include "dialogokno.h" DialogOkno::DialogOkno(QWidget *parent) : QWidget(parent) { // QLabel *openGLLabel = new QLabel(tr("OpenGL")); // GLWidget *openGL = new GLWidget(&helper, this); MyGLWidget * openGL = new MyGLWidget(parent); // обявл элементы gl_layaout[0] = new QGridLayout(parent); gl_layaout[1] = new QGridLayout(parent); gl_layaout[2] = new QGridLayout(parent); gl_layaout[3] = new QGridLayout(parent); openGLWidget = new QOpenGLWidget(parent); l_label[0] = new QLabel(parent); l_label[1] = new QLabel(parent); l_label[2] = new QLabel(parent); le_edit[0] = new QLineEdit(parent); le_edit[1] = new QLineEdit(parent); le_edit[2] = new QLineEdit(parent); le_edit[3] = new QLineEdit(parent); le_edit[4] = new QLineEdit(parent); le_edit[5] = new QLineEdit(parent); le_edit[6] = new QLineEdit(parent); // настройки элеметов (стилизация) // заполнение элементов l_label[0]->setText("hla_global"); l_label[1]->setText("hla_local"); l_label[2]->setText("logger"); le_edit[0]->setText("server_ip_global"); le_edit[1]->setText("server_port_global"); le_edit[2]->setText("server_port_local"); le_edit[3]->setText("server_port_local"); le_edit[4]->setText("log"); le_edit[5]->setText("log_period_ms"); le_edit[6]->setText("log_size_in_mb"); //разложение элементов по группам gl_layaout[0]->addWidget(l_label[0], 0, 0, 1, 1); gl_layaout[0]->addWidget(le_edit[0], 1, 0, 1, 1); gl_layaout[0]->addWidget(le_edit[1], 2, 0, 1, 1); gl_layaout[1]->addWidget(l_label[1], 0, 0, 1, 1); gl_layaout[1]->addWidget(le_edit[2], 1, 0, 1, 1); gl_layaout[1]->addWidget(le_edit[3], 2, 0, 1, 1); gl_layaout[2]->addWidget(l_label[2], 0, 0, 1, 1); gl_layaout[2]->addWidget(le_edit[4], 1, 0, 1, 1); gl_layaout[2]->addWidget(le_edit[5], 2, 0, 1, 1); gl_layaout[2]->addWidget(le_edit[6], 3, 0, 1, 1); gl_layaout[3]->addLayout(gl_layaout[0], 0, 0, 1, 1); si_spacer[0] = new QSpacerItem(120, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); // gl_layaout[3]->addWidget(si_spacer[0], 0, 1, 1, 1); gl_layaout[3]->addItem(si_spacer[0], 0, 1, 1, 1); gl_layaout[3]->addLayout(gl_layaout[1], 0, 2, 1, 1); si_spacer[1] = new QSpacerItem(120, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); // gl_layaout[3]->addWidget(si_spacer[1], 0,3, 1, 1); gl_layaout[3]->addItem(si_spacer[1], 0, 3, 1, 1); si_spacer[2] = new QSpacerItem(20, 82, QSizePolicy::Minimum, QSizePolicy::Expanding); // gl_layaout[3]->addWidget(si_spacer[2], 1,0, 1, 1); gl_layaout[3]->addItem(si_spacer[2],1, 0, 1, 1); gl_layaout[3]->addLayout(gl_layaout[2], 2, 0, 1, 1); si_spacer[3] = new QSpacerItem(20, 82, QSizePolicy::Minimum, QSizePolicy::Expanding); // gl_layaout[3]->addWidget(si_spacer[3], 3,0, 1, 1); gl_layaout[3]->addItem(si_spacer[3], 3, 0, 1, 1); // gl_layaout[3]->addWidget(openGLWidget, 1, 1, 3, 3); gl_layaout[3]->addWidget(openGL , 1, 1, 3, 3); // gl_layaout[3]->addLayout(gl_layaout[0], 0,0); // gl_layaout[3]->addLayout(gl_layaout[1], 1,0); // gl_layaout[3]->addLayout(gl_layaout[2], 2,0); this->setLayout(gl_layaout[3]); } DialogOkno::~DialogOkno() { }
-
And this example still has the errors? Then simplify it (and fix the memleaks - a new[] needs a delete[] and paintGL() is not called only once so your vectors grow indefinitly) until we can really try it out. E.g. loading an object file is not needed - drawing a simple rectangle to reproduce the issue is enough.