Hi.

I've downloaded a simple application to see how I can draw using Opengl.

The project has only the main.cpp that have the following code:
Qt Code:
  1. #include <QtGui/QApplication>
  2. #include <QGLWidget>
  3. #include <QHBoxLayout>
  4. #include <QSize>
  5. #include <QPushButton>
  6.  
  7. class MyGLWidget : public QGLWidget
  8. {
  9. Q_OBJECT
  10. public:
  11. MyGLWidget (QWidget* parent ) : QGLWidget(parent)
  12. {
  13. }
  14. float red, blue, green;
  15. void initializeGL()
  16. {
  17. red = 0;
  18. blue = 0;
  19. green = 0;
  20. }
  21.  
  22. public slots:
  23.  
  24. void resetColor()
  25. {
  26. red = 0;
  27. blue = 0;
  28. green = 0;
  29. update();
  30. }
  31.  
  32. void paintGL()
  33. {
  34. red += 0.007;
  35. blue += 0.002;
  36. green += 0.005;
  37. glClearColor(red,green,blue,0);
  38. glClear(GL_COLOR_BUFFER_BIT);
  39. }
  40. };
  41.  
  42.  
  43. class MiaMainWindow:public QWidget
  44. {
  45. public:
  46. MiaMainWindow ():QWidget(NULL){
  47. MyGLWidget *glWidget = new MyGLWidget(this);
  48. QHBoxLayout *layout = new QHBoxLayout(this);
  49. QPushButton *button = new QPushButton("Get to the Choppa!!!", this);
  50. setLayout(layout);
  51. layout->addWidget(glWidget);
  52. layout->addWidget(button);
  53. connect(button, SIGNAL(clicked()),glWidget, SLOT(resetColor()));
  54. setWindowTitle("Hello World!");
  55. sizeHint();
  56. }
  57.  
  58. QSize sizeHint() const
  59. {
  60. return QSize(100,100);
  61. }
  62.  
  63. };
  64.  
  65. int main(int argc, char** argv){
  66.  
  67. QApplication app(argc, argv);
  68. MiaMainWindow win;
  69. win.show();
  70. int res = app.exec();
  71. return res;
  72. }
To copy to clipboard, switch view to plain text mode 

and the .pro is the following one:

Qt Code:
  1. #-------------------------------------------------
  2. #
  3. # Project created by QtCreator 2011-09-14T20:01:51
  4. #
  5. #-------------------------------------------------
  6.  
  7. QT += core
  8. QT += gui
  9. QT += opengl
  10.  
  11. TARGET = tryme
  12. CONFIG += console
  13. CONFIG -= app_bundle
  14. TEMPLATE = app
  15. SOURCES += main.cpp
To copy to clipboard, switch view to plain text mode 

But, when I compile it (using qtcreator 2.3.0 with Qt 4.7.4 and MinGW 4.4), I've the following errror:

debug/main.o: In function `MyGLWidget':
dir\tryme-build-desktop-Qt_4_7_3_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../tryme/main.cpp:12: undefined reference to `vtable for MyGLWidget'
dir\tryme-build-desktop-Qt_4_7_3_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../tryme/main.cpp:12: undefined reference to `vtable for MyGLWidget'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\tryme.exe] Error 1
mingw32-make: *** [debug] Error 2
The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project tryme (target: Desktop)
When executing build step 'Make'
I've read something about this error but I don't know where's the error. Can anyone help me, please?

Thanks in advance for your replies.

Regards.