'Qt Raise window to foreground without giving focus

I have some situations where I'd like to raise my window to the foreground without giving it focus. I was using platform-specific dependencies to do this before (in Python), but I'm hoping this is possible directly in Qt.

I've tried a number of different combinations with .raise_, .activateWindow, .setWindowState and toggling Qt.WA_ShowWithoutActivating with .setAttribute, but I've had little success in being able to choose between giving and not giving focus. There doesn't seem to be a direct way to achieve this, but it feels like there's some gimmicky combination here that would let you do it anyway.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source