Unsolved Problems when running the first program in QT Creator with OpenGL
-
Hi everyone,
Hi,
I am trying to run basic examples of OpenGL using QT Creator to give color to a window. However, I am getting error in the compilation when calling the OpenGL instruction:
glClearColor(1.0,1.0,0.0,1.0);The *.pro file is the next:
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test2
TEMPLATE = app
SOURCES += main.cpp
mainwindow.cpp
glwidget.cpp
HEADERS += mainwindow.h
glwidget.h
FORMS += mainwindow.uiThe glwidget.h is the next:
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QGLWidget>
class GLWidget : public QGLWidget
{
Q_OBJECT
public:
explicit GLWidget(QWidget *parent = 0);
void initializeGL();
};
#endif // GLWIDGET_HThe glwidget.cpp is the next:
#include "glwidget.h"
GLWidget::GLWidget(QWidget *parent) :
QGLWidget(parent)
{
}
void GLWidget::initializeGL(){
glClearColor(1.0,1.0,0.0,1.0);
}The main.cpp:
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}I have checked that in the *.pro I have included opengl:
QT += core gui opengl
In addition, I have deleted the YourProjectName-build-desktop folder and build again without success.Which extra step I am missing?
Thank you in advance for your help
Cheers
-
Hi,
Could you show us the error message please?