I searched this a bit more.
First of all the behavior might be depending on OS. (Noticed some differences on Unix vs Windows)
Secondly, I created a timer that every 2 seconds prints out qApp->focusObject(). It looks like after a QEvent::ApplicationStateChange and a QEvent::WindowDeactivate that all the widgets receive afterwards, the qApp->focusObject() is always nullptr. And after nullptr Qt selects the widget on MainWindow that was the last widget to have focus, and gives focus there.
So I feel that subwindows are ignored somehow...
I am leaving this open for a bit, in case someone has a good solution to track if a subwindow had focus, it should regain it after application re activation.