I have a Qt application that always stays on top. Now, i want to hide the window if the user clicks a specific area outside the Qt window. So, if user clicks outside the Qt window and outside the specific coordinates, nothing should happen and if he clicks outside the window but inside the specific coordinates the Qt window should hide. I have this code as of now:

Qt Code:
  1. if (event->type() == QEvent::FocusOut)
  2. {
  3. qDebug("focus lost");
  4. return true;
  5. }
  6. else if(event->type() == QEvent::MouseButtonPress)
  7. {
  8. QPoint pos = dynamic_cast<QMouseEvent*>(event)->pos();
  9. qDebug() << "mouse click position=" << mapToGlobal(pos) << "global=" << dynamic_cast<QMouseEvent*>(event)->globalPos();
  10. return false;
  11. }
To copy to clipboard, switch view to plain text mode 

Using the above code, i get the focus lost event when user clicks outside the Qt window but i don't get the coordinates of the click event. QEvent::MouseButtonPress case is executed only when user clicks the mouse inside the Qt window. Is there any way of getting the global mouse coordinates when user clicks outside the Qt window?