The return value is always Qt :: NoButton for mouse move events . You can use an event filter to solve this problem.
try it
bool MainWindow::eventFilter(QObject *object, QEvent *e) { if (e->type() == QEvent::MouseButtonPress && QApplication::mouseButtons()==Qt::LeftButton) { leftbuttonpressedflag=true; } if (e->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(e); if(leftbuttonpressedflag && mouseEvent->pos()==Inside_Graphics_Scene) qDebug("MouseDrag On GraphicsScene"); } return false; }
And also do not forget to set this event filter in mainwindow.
qApplicationobject->installEventFilter(this);
source share