@SGaist,
Qt 6.3.2, Windows 10.
I found that winapi coordinates I got eventually turned out to be different from QCursor::pos() when talking about switching between different scales. So I decided to use QCursor::pos() instead, and it helped:
QPoint globalCursorPos = QCursor::pos();
auto menuGeom = ui.qMenuBarMain->geometry().translated(ui.qMenuBarMain->mapToGlobal(QPoint(0, 0)));
if (menuGeom.contains(globalCursorPos))
//some work