Hello,
In a QDialog, I would like to display the mouse coordinates when the mouse is above a widget which is included in the QDialog.
Using "setMouseTracking", it works when the widget is a QLabel but it doesn't when it is a QGraphicsView : if the mouse moved above the qgraphicsview, the function mouseMoveEvent of the QDialog isn't called. Why ?

Example:
Qt Code:
  1. #include <QDialog>
  2. #include <QGridLayout>
  3. #include <QDebug>
  4. #include <QApplication>
  5. #include <QGraphicsView>
  6. #include <QGraphicsScene>
  7. #include <QLabel>
  8.  
  9. class MyDialog : public QDialog
  10. {
  11. public:
  12. MyDialog() : QDialog()
  13. {setMouseTracking(true);}
  14. protected:
  15. void mouseMoveEvent(QMouseEvent *event)
  16. {
  17. qDebug()<<QCursor::pos();
  18. }
  19. };
  20.  
  21. int main(int argc, char **argv){
  22. QApplication app(argc, argv);
  23. MyDialog dlg;
  24. QGridLayout *l = new QGridLayout(&dlg);
  25. QLabel* label1 = new QLabel("Above Label");
  26. label1->setMouseTracking(true);
  27. QGraphicsScene* scene = new QGraphicsScene(0, 0, 100, 100);
  28. QGraphicsView* view = new QGraphicsView(scene);
  29. view->setMouseTracking(true);
  30. l->addWidget(label1,0, 0);
  31. l->addWidget(view, 0, 1, 2, 1);
  32. return dlg.exec();
  33. }
To copy to clipboard, switch view to plain text mode 

Thank you.