Rectangle 27 0

Alright heres how I solved this problem. The event system in Qt, any application I assume, won't register events when the window is not active. However the process is obviously still running so data you can access while the window is active you can access whilst the window is no longer active.

Use a timed poll method to get the mouse position every n seconds

//Method used to hopefully track the mouse regardless of whether or not it is inside the active window
void MainWindow::pollMouse(unsigned long sec)
    //Loop forever
    while ( true )
        QPoint mouseLoc = QCursor::pos();
        qDebug() << "Mouse position global: x,y"  << mouseLoc.x() << mouseLoc.y();


c++ - Qt get mouse events outside of the application window - Stack Ov...

c++ qt mouseevent x11