qApp->activeWindow() is incorrect when clicking to another window after a button menu popup was shown. Does not matter if you click the other window's titlebar or in any empty layout area. When the popup action is selected or closed, this problem goes away. Please see screen shot. I attached a small program to reproduce it. The bug is similar on macos 10.13.3 and qt 5.7.0 and 5.9.2.