Results 1 to 2 of 2

Thread: Problem with 'm_backgroundColor' in a QGraphicsScene's subclass

  1. #1
    Join Date
    Oct 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Problem with 'm_backgroundColor' in a QGraphicsScene's subclass

    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:
    Qt Code:
    1. //************************
    2. // openglscene.h
    3. //************************
    4. #ifndef OPENGLSCENE_H
    5. #define OPENGLSCENE_H
    6.  
    7. #include <QtCore/QString>
    8. #include <QtCore/QTimer>
    9. #include <QtGui/QKeyEvent>
    10. #include <QtGui/QApplication>
    11. #include <QtOpenGL/QGLWidget>
    12. #include <QtGui/QMainWindow>
    13. #include <QtGui/QMdiSubWindow>
    14. #include <QtGui/QMdiArea>
    15. #include <QGraphicsView>
    16. #include <QGraphicsScene>
    17. #include <QTextCursor>
    18. #include <QDialog>
    19. #include <QKeyEvent>
    20. #include <QFile>
    21. #include <QTextStream>
    22. #include <QMessageBox>
    23. #include <QMenu>
    24. #include <QTextDocumentFragment>
    25. #include <QScrollBar>
    26. #include <QPainter>
    27. #include <QDebug>
    28. #include <QListWidget>
    29. #include <QProcess>
    30. #include <QClipboard>
    31. #include <QFileInfo>
    32. #include <QPrintDialog>
    33. #include <QTime>
    34. #include <QTextLayout>
    35. #include <QTextCodec>
    36. #include <QDir>
    37. #include <QPaintEngine>
    38. #include <QColormap>
    39. #include <QtCore>
    40. #include <QtGui>
    41. #include <QtOpenGL>
    42.  
    43. using namespace std;
    44.  
    45. class OpenGLScene : public QGraphicsScene{
    46. public:
    47. OpenGLScene();
    48.  
    49. protected:
    50. void drawBackground ( QPainter *painter, const QRectF & );
    51. };
    52. #endif
    53.  
    54. //************************
    55. // openglscene.cpp
    56. //************************
    57. #include "openglscene.h"
    58.  
    59. OpenGLScene:penGLScene(){}
    60.  
    61. void OpenGLScene::drawBackground ( QPainter *painter, const QRectF & ){
    62. if ( painter->paintEngine()->type() != QPaintEngine:penGL ){
    63. qWarning ( "OpenGLScene: drawBackground needs a QGLWidget to be set as viewport on the graphics view" );
    64. return;
    65. }
    66.  
    67. glClearColor( m_backgroundColor.redF(), m_backgroundColor.greenF(), m_backgroundColor.blueF(), 1.0f );
    68. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    69. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with 'm_backgroundColor' in a QGraphicsScene's subclass

    There is no m_backgroundColor variable in your class, is there?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 8
    Last Post: 12th February 2010, 02:41
  2. QGraphicsScene problem/bug
    By rubenvb in forum Qt Programming
    Replies: 2
    Last Post: 27th September 2009, 23:34
  3. QGraphicsTextItem subclass & QGraphicsScene
    By ttvo in forum Qt Programming
    Replies: 2
    Last Post: 30th August 2009, 15:46
  4. Problem emiting signal in QTreeWidgetItem's subclass
    By Shawn in forum Qt Programming
    Replies: 12
    Last Post: 4th September 2007, 12:08
  5. problem of subclass QTableItem
    By hesummar in forum Qt Programming
    Replies: 1
    Last Post: 4th November 2006, 09:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.