Hi all,


I would like to know on wich position a user clicked in the scene.
I know I have to do this with the mousePressEvent(QGrapicsSceneMouseEvent *event),
but it just aint working...

This code pops me a dialog when I click anywhere on my form, except when I click in the scene:
Qt Code:
  1. void GUIGame::mousePressEvent(QMouseEvent *event){
  2.  
  3. QMessageBox::about(this,"xxxx!","yyyyy!");
  4.  
  5. }
To copy to clipboard, switch view to plain text mode 

When I change this event like this:

Qt Code:
  1. void GUIGame::mousePressEvent(QGraphicsSceneMouseEvent *event){
  2.  
  3. QMessageBox::about(this,"xxxx!","yyyyy!");
  4.  
  5. }
To copy to clipboard, switch view to plain text mode 
it does'nt do anything.

The constructor of my mainwindow is like this:

Qt Code:
  1. GUIGame::GUIGame() : QMainWindow(0, Qt::WindowFlags())
  2. {
  3. setWindowTitle(tr("DuckBoard"));
  4. setWindowIcon(QPixmap("logo.png"));
  5.  
  6. this->setWindowState(Qt::WindowMaximized);
  7. setWindowTitle(tr("DuckBoard"));
  8. setWindowIcon(QPixmap("logo.png"));
  9. gamemenu = menuBar()->addMenu(tr("&Game"));
  10. gamemenu->addAction(QPixmap("icons/wand.png"), tr("&New"), this, SLOT(newGame()), QKeySequence("Ctrl+N"));
  11. gamemenu->addAction(QPixmap("icons/cancel.png"), tr("&Quit"), this, SLOT(close()), QKeySequence("Ctrl+Q"));
  12.  
  13. helpmenu = menuBar()->addMenu(tr("&Help"));
  14. helpmenu->addAction(QPixmap("icons/rosette.png"), tr("&Credits"), this, SLOT(credits()), QKeySequence("Ctrl+C"));
  15. helpmenu->addAction(QPixmap("icons/help.png"), tr("&Help"), this, SLOT(help()), QKeySequence("Ctrl+H"));
  16. canvas = new QGraphicsScene;
  17. canvas->setSceneRect(0,0,640,640);
  18. view = new QGraphicsView(canvas, NULL);
  19. view->setFixedSize(642,642);
  20. view->setAlignment(Qt::AlignLeft);
  21. gamelog = new logGUI(this);
  22. setBord(new Bord());
  23. m_GUIBord = new BordGUI(canvas, geefBord());
  24. setDobbel(new Dobbel());
  25. m_GUIDobbel = new DobbelGUI(this);
  26. QWidget *test = new QWidget;
  27. QHBoxLayout *layout = new QHBoxLayout;
  28. QVBoxLayout *layout2 = new QVBoxLayout;
  29. layout->addWidget(view);
  30. layout2->addWidget(m_GUIDobbel);
  31. layout2->addWidget(gamelog);
  32. layout->addLayout(layout2);
  33. test->setLayout(layout);
  34. setCentralWidget(test);
  35. int j = 1+1;
  36. int i=0;
  37. disableBeforePlay();
  38. gedaan = false;
  39. aandebeurt = 0;
  40.  
  41. connect(m_GUIDobbel->geefWerpKnop(), SIGNAL(clicked()), this, SLOT(zetPion()));
  42. }
To copy to clipboard, switch view to plain text mode 

Does anyone knows how I can activate the mousePressEvent for my scene?

Thanks in advance!