Hi there! I am stuck with a very basic problem with the QGLWidget. The space of the widget is just black, the overwritten methods of my own subclass of QGLWidget, initializeGL resizeGL paintGL, are never called (checked with breakpoints).
So I went back to the Hello GL example, which works correctly. But I can't find noticable difference to the Hello GL example. There the resizeGL gets called with the show() of the window widget. In my program the method is NOT called.
What am I missing so the xGL methods of MyGLViewer get called?

main.cpp
Qt Code:
  1. #include <QtGui/QApplication>
  2. #include "WindowWidget.h"
  3. int main(int argc, char *argv[])
  4. {
  5. QApplication a(argc, argv);
  6. WindowWidget w;
  7. w.show();
  8. return a.exec();
  9. }
To copy to clipboard, switch view to plain text mode 

my window class WindowWidget, that does nothing but to add the ogl-widget.
Qt Code:
  1. #include "WindowWidget.h"
  2. #include "ui_WindowWidget.h"
  3. WindowWidget::WindowWidget(QWidget *parent) : QWidget(parent), ui(new Ui::WindowWidget) {
  4. ui->setupUi(this);
  5. viewer = new MyGLViewer(this);
  6. QHBoxLayout* layout = new QHBoxLayout();
  7. layout->addWidget(viewer);
  8. setLayout(layout);
  9. }
  10. WindowWidget::~WindowWidget() { delete ui; }
  11.  
  12. ---
  13.  
  14. #ifndef WINDOWWIDGET_H
  15. #define WINDOWWIDGET_H
  16. #include <QWidget>
  17. #include "MyGLViewer.h"
  18.  
  19. namespace Ui { class WindowWidget; }
  20.  
  21. class WindowWidget : public QWidget {
  22. Q_OBJECT
  23. public:
  24. explicit WindowWidget(QWidget *parent = 0);
  25. ~WindowWidget();
  26. protected:
  27. Ui::WindowWidget *ui;
  28. MyGLViewer* viewer;
  29. };
  30. #endif // WINDOWWIDGET_H
To copy to clipboard, switch view to plain text mode 

my QGLWidget subclass with method stubs. I check if they are called with breakpoints.
Qt Code:
  1. #ifndef MYGLVIEWER_H
  2. #define MYGLVIEWER_H
  3.  
  4. #include <QGLWidget>
  5. #include <QtOpenGL>
  6.  
  7. class MyGLViewer : public QGLWidget {
  8. Q_OBJECT
  9. public:
  10. MyGLViewer(QWidget *parent=0) : QGLWidget(parent) {}
  11. protected:
  12. void initializeGL() {
  13. // Set up the rendering context, define display lists etc.:
  14. ...
  15. }
  16.  
  17. void resizeGL(int w, int h) {
  18. // setup viewport, projection etc.:
  19. ...
  20. }
  21.  
  22. void paintGL() {
  23. // draw the scene:
  24. ...
  25. }
  26. };
  27. #endif // MYGLVIEWER_H
To copy to clipboard, switch view to plain text mode