parent pyqt window/widget to blender's window

I’ve got PyQt5 widgets working well inside blender and interacting with the scene and blenders python api however if i click on blender the PyQt widgets i’ve made will go behind it.

Essentially I am trying to parent a QMainWindow to a non-qt application. Any ideas on how to do this?

I could use Qt.WindowStaysOnTopHint flag but then it’s on top of everything which isn’t ideal and if i want to switch that flag off i would still need a way of identifying that blender is in focus or not in focus (like if i minimize it or access some other application).

Using Linux.

Cheers