Hello,

I am still pretty new to Qt and it is pretty different from most of the editors I have ever used before. I have started a simple project - When you click on a QGraphicsScene it draws a red background. However, upon clicking on the scene it crashes the program.

Can anyone see where I went wrong, for the life of me I cannot figure this one out?

Scene Class:

Qt Code:
  1. class scene2 : public QGraphicsScene
  2. {
  3. #include <QMessageBox>
  4.  
  5. public:
  6. void mousePressEvent(QGraphicsSceneMouseEvent *event);
  7. };
To copy to clipboard, switch view to plain text mode 

Set's Scene To View:
Qt Code:
  1. MainWindow::MainWindow(QWidget *parent) :
  2. QMainWindow(parent),
  3. ui(new Ui::MainWindow)
  4. {
  5. ui->setupUi(this);
  6.  
  7. scene = new scene2;
  8. ui->GraphicsMap->setScene(scene);
  9. scene->setSceneRect(0,0,900,900);
  10. }
To copy to clipboard, switch view to plain text mode 

On Click:
Qt Code:
  1. void scene2::mousePressEvent(QGraphicsSceneMouseEvent *event)
  2. {
  3. QBrush whiteBrush(Qt::red);
  4. scene->setBackgroundBrush(whiteBrush);
  5. }
To copy to clipboard, switch view to plain text mode 

Thanks for any help guys,
Matt <Noob>