Reputation: 3147
In the project that use OpenGL in Qt I use in protected method initializeGL() the statement
qglClearColor(qtPurple.dark());
Follows errors occurs in the building project:
‘qtPurple’ was not declared in this scope
‘qglClearColor’ was not declared in this scope
The files that is included is:
#include <QtGui>
#include <QtOpenGL>
#include <QtGui/QColor>
In the .pro file is present
QT += core gui, opengl
Where are the mistakes that cause these errors?
Upvotes: 0
Views: 1316
Reputation: 6326
Add #include <QtOpenGL/QGLWidget>
in your head file.And Your class should inherit QGLWidget
.
It seems that you have not declared the variable qtPurple
,so check
your head file,if not exist,just declare it[like this:QColor qtPurple;
].
Upvotes: 1
Reputation: 8238
QGLClearColor
is a non-static member of QGLWidget
. So first you must include <QGLWidget>
to your widget header file and inherit your widget from QGLWidget. Then you will be able to call it in methods of your widget. You get was not declared in this scope
error because qglClearColor
is in QGLWidget
scope.
Alternatively, you can call it as regular method of your widget object.
And what is qtPurple
? It seems that it's not a part of Qt.
Upvotes: 2