we need to get the cursor position every time when we move the mouse on desktop.
Qt Code:
  1. bool MainWindow::eventFilter(QObject *obj, QEvent *event)
  2. {
  3. if (event->type() == QEvent::MouseMove)
  4. {
  5. QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
  6. qDebug()<<"event Filter Mouse Move"<<mouseEvent->pos().x()<<mouseEvent->pos().y();
  7. }
  8. if (event->type() == QEvent::FocusOut)
  9. {
  10. QFocusEvent *focusEvent = static_cast<QFocusEvent*>(event);
  11. focusEvent->accept();
  12. qDebug()<<"event Filter Mouse Move111"<<QCursor::pos();
  13. }
  14. return false;
  15. }
To copy to clipboard, switch view to plain text mode 
Using the above we can get the cursor position inside the Qt application and also get the cursor position when we click on the window outside the Qt app.In our project we need the cursor position on Mousemove outside the QT app.How can we do this ?