PDA

View Full Version : Problem with 'm_backgroundColor' in a QGraphicsScene's subclass



kayss
25th October 2010, 12:53
Hi!

I'm trying to do a subclass of QGraphicsScene to draw a OpenGL scene into a QT's widget and when I compile this it give me the follow error:

'm_backgroundColor' was not declared in this scope

I am looking for the problem and I don't find it.
Please, I hope someone can help me.

I'm using KDevelop 3.5.10 and QT4
This is my code:


//************************
// openglscene.h
//************************
#ifndef OPENGLSCENE_H
#define OPENGLSCENE_H

#include <QtCore/QString>
#include <QtCore/QTimer>
#include <QtGui/QKeyEvent>
#include <QtGui/QApplication>
#include <QtOpenGL/QGLWidget>
#include <QtGui/QMainWindow>
#include <QtGui/QMdiSubWindow>
#include <QtGui/QMdiArea>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QTextCursor>
#include <QDialog>
#include <QKeyEvent>
#include <QFile>
#include <QTextStream>
#include <QMessageBox>
#include <QMenu>
#include <QTextDocumentFragment>
#include <QScrollBar>
#include <QPainter>
#include <QDebug>
#include <QListWidget>
#include <QProcess>
#include <QClipboard>
#include <QFileInfo>
#include <QPrintDialog>
#include <QTime>
#include <QTextLayout>
#include <QTextCodec>
#include <QDir>
#include <QPaintEngine>
#include <QColormap>
#include <QtCore>
#include <QtGui>
#include <QtOpenGL>

using namespace std;

class OpenGLScene : public QGraphicsScene{
public:
OpenGLScene();

protected:
void drawBackground ( QPainter *painter, const QRectF & );
};
#endif

//************************
// openglscene.cpp
//************************
#include "openglscene.h"

OpenGLScene:penGLScene(){}

void OpenGLScene::drawBackground ( QPainter *painter, const QRectF & ){
if ( painter->paintEngine()->type() != QPaintEngine:penGL ){
qWarning ( "OpenGLScene: drawBackground needs a QGLWidget to be set as viewport on the graphics view" );
return;
}

glClearColor( m_backgroundColor.redF(), m_backgroundColor.greenF(), m_backgroundColor.blueF(), 1.0f );
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

wysota
25th October 2010, 13:07
There is no m_backgroundColor variable in your class, is there?