I'm fairly new to Qt. I'm trying to make a custom VJ application. For my video-output I want to use OpenGL, which I control by another mainwindow. The problem is, It just renders black. I copypasted what the NeHe tutorial says for drawing a simple white triangle and rectangle, but it's still black. I don't get what's wrong with it. Is there anything I missed?
this is my glscreen.h
Qt Code:
  1. #ifndef GLSCREEN_H
  2. #define GLSCREEN_H
  3.  
  4. #include <QMainWindow>
  5. #include <QGLWidget>
  6.  
  7. class VJOutput : public QGLWidget{
  8. Q_OBJECT
  9. public:
  10. VJOutput();
  11. protected:
  12. void initializeGL();
  13. void paintGL();
  14. void resizeGL(int w, int h);
  15. public slots:
  16. void Herteken();
  17.  
  18. };
  19.  
  20.  
  21. #endif // GLSCREEN_H
To copy to clipboard, switch view to plain text mode 

here's the glscreen.cpp code

Qt Code:
  1. #include "glscreen.h"
  2. #include "ui_glscreen.h"
  3. #include <iostream>
  4. #include <QTimer>
  5. #include <math.h>
  6.  
  7. void VJOutput::initializeGL(){
  8. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
  9. glLoadIdentity(); // Reset The View
  10. }
  11. VJOutput::VJOutput(){
  12. initializeGL();
  13. QTimer *RedrawTimer = new QTimer(this);
  14. connect(RedrawTimer,SIGNAL(timeout()),this,SLOT(Herteken()));
  15. RedrawTimer->start(20);
  16.  
  17. }
  18. void VJOutput::resizeGL(int w, int h){
  19.  
  20. }
  21.  
  22. void VJOutput::paintGL(){
  23. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  24. glLoadIdentity();
  25.  
  26. glTranslatef(-1.5f,0.0f,-6.0f);
  27.  
  28. glBegin(GL_TRIANGLES);
  29. glVertex3f( 0.0f, 1.0f, 0.0f);
  30. glVertex3f(-1.0f,-1.0f, 0.0f);
  31. glVertex3f( 1.0f,-1.0f, 0.0f);
  32. glEnd();
  33.  
  34. glTranslatef(3.0f,0.0f,0.0f);
  35.  
  36. glBegin(GL_QUADS);
  37. glVertex3f(-1.0f, 1.0f, 0.0f);
  38. glVertex3f( 1.0f, 1.0f, 0.0f);
  39. glVertex3f( 1.0f,-1.0f, 0.0f);
  40. glVertex3f(-1.0f,-1.0f, 0.0f);
  41. glEnd();
  42. }
  43. void VJOutput::Herteken(){
  44. updateGL();
  45. }
To copy to clipboard, switch view to plain text mode 
my VJ.pro file has:
Qt Code:
  1. # -------------------------------------------------
  2. # Project created by QtCreator 2010-01-15T13:07:06
  3. # -------------------------------------------------
  4. QT += network \
  5. opengl \
  6. sql \
  7. xml \
  8. xmlpatterns \
  9. phonon \
  10. dbus
  11. CONFIG += thread
  12. TARGET = VJ
  13. TEMPLATE = app
  14. SOURCES += main.cpp \
  15. mainwindow.cpp \
  16. lib/Rhythm.cpp \
  17. lib/MidiDevices.cpp \
  18. lib/RtMidi.cpp \
  19. visualLib/glscreen.cpp
  20. HEADERS += mainwindow.h \
  21. lib/Rhythm.h \
  22. lib/MidiDevices.h \
  23. lib/RtMidi.h \
  24. lib/RtError.h \
  25. visualLib/glscreen.h
  26. LIBS += -L/alsa/ \
  27. -lasound \
  28. -lpthread
  29. FORMS += mainwindow.ui
To copy to clipboard, switch view to plain text mode 

I'm using ubuntu and Qt Creator