I am a newbie in QT and working with its openGL in the Ubuntu Platform

I have created a template as in :

worktable.jpg

My objective :

On clicking of the "Compute" Button, two things are supposed to happen :

1> A text will be printed in the in the text box 2> A line will be drawn on expOutput, which is an object of Experimental, inherited from QGLWidget.

I am creating two signal slots. The codes of the program is given as below :

nearestneighbour.h

Qt Code:
  1. #ifndef NEARESTNEIGHBOUR_H
  2. #define NEARESTNEIGHBOUR_H
  3.  
  4. #include <QWidget>
  5. #include <QGLWidget>
  6.  
  7. namespace Ui {
  8. class NearestNeighbour;
  9. }
  10.  
  11. class NearestNeighbour : public QWidget
  12. {
  13. Q_OBJECT
  14.  
  15. public:
  16. explicit NearestNeighbour(QWidget *parent = 0);
  17. ~NearestNeighbour();
  18.  
  19. signals:
  20. void clicked();
  21.  
  22. private slots:
  23. void on_Compute_clicked();
  24.  
  25. private:
  26. Ui::NearestNeighbour *ui;
  27. };
  28.  
  29. #endif // NEARESTNEIGHBOUR_H
To copy to clipboard, switch view to plain text mode 

nearestneighbour.cpp

Qt Code:
  1. #include "nearestneighbour.h"
  2. #include "ui_nearestneighbour.h"
  3.  
  4. NearestNeighbour::NearestNeighbour(QWidget *parent) :
  5. QWidget(parent),
  6. ui(new Ui::NearestNeighbour)
  7. {
  8. ui->setupUi(this);
  9. QObject::connect(ui->Compute, SIGNAL(clicked()), ui->expOutput,SLOT(draw()));
  10. QObject::connect(ui->Compute, SIGNAL(clicked()), ui->textEdit,SLOT(on_Compute_clicked()));
  11. }
  12.  
  13. NearestNeighbour::~NearestNeighbour()
  14. {
  15. delete ui;
  16. }
  17.  
  18.  
  19. void NearestNeighbour::on_Compute_clicked()
  20. {
  21. ui->textEdit->setText("Hello World !!");
  22. }
To copy to clipboard, switch view to plain text mode 

experimental.h

Qt Code:
  1. #ifndef EXPERIMENTAL_H
  2. #define EXPERIMENTAL_H
  3.  
  4. #include <QWidget>
  5. #include <QGLWidget>
  6. #include "nearestneighbour.h"
  7. #include "ui_nearestneighbour.h"
  8.  
  9. class Experimental : public QGLWidget
  10. {
  11. Q_OBJECT
  12. public:
  13. explicit Experimental(QWidget *parent=NULL);
  14.  
  15.  
  16. public slots:
  17. void draw();
  18.  
  19. protected:
  20. void initializeGL();
  21. void paintGL();
  22.  
  23. };
  24.  
  25. #endif // EXPERIMENTAL_H
To copy to clipboard, switch view to plain text mode 

experimental.cpp

Qt Code:
  1. #include "experimental.h"
  2.  
  3. Experimental::Experimental(QWidget *parent): QGLWidget(QGLFormat(QGL::SampleBuffers), parent){}
  4.  
  5. void Experimental::initializeGL(){
  6. qglClearColor(Qt::white);
  7. glEnable(GL_DEPTH_TEST);
  8. glEnable(GL_CULL_FACE);
  9. glShadeModel(GL_SMOOTH);
  10. }
  11.  
  12. void Experimental::paintGL(){
  13. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  14. glLoadIdentity();
  15. qglColor(Qt::black);
  16. glBegin(GL_LINE);
  17. glVertex2i(0,0);
  18. glVertex2i(200,200);
  19. glEnd();
  20. }
  21.  
  22. void Experimental::draw(){
  23.  
  24. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  25. glLoadIdentity();
  26. qglColor(Qt::black);
  27. glBegin(GL_LINE);
  28. glVertex2i(0,0);
  29. glVertex2i(200,200);
  30. glEnd();
  31. updateGL();
  32. }
To copy to clipboard, switch view to plain text mode 

Problem :

1> Whenever, I compile the program, the following error creeps up :

Qt Code:
  1. In file included from ../NearestNeighbour/experimental.h:7:0,
  2. from ../NearestNeighbour/experimental.cpp:1:
  3. ./ui_nearestneighbour.h:28:5: error: ‘Experimental’ does not name a type; did you mean ‘isprint_l’?
  4. Experimental *expOutput;
  5. ^~~~~~~~~~~~
  6. isprint_l
  7. ./ui_nearestneighbour.h: In member function ‘void Ui_NearestNeighbour::setupUi(QWidget*):
  8. ./ui_nearestneighbour.h:38:9: error: ‘expOutput’ was not declared in this scope
  9. expOutput = new Experimental(NearestNeighbour);
  10. ^~~~~~~~~
  11. ./ui_nearestneighbour.h:38:25: error: expected type-specifier before ‘Experimental’
  12. expOutput = new Experimental(NearestNeighbour);
  13. ^~~~~~~~~~~~
To copy to clipboard, switch view to plain text mode 

2> No output is being shown in the openGL widget