parent pyqt window/widget to blender's window

Creating pyqt windows/widgets in blender and interacting with blenders python api.
So far everything seems to be working fine however if i click on blender the qt window will go behind blender window.

Essentially I am trying to parent a QMainWindow to a non-qt application (blender). 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 i would still need to identify blender being minimized or some other application taking focus.

Using Linux.

Also: in case anyone is wondering why I’m not using blenders gui features is because the tools I’m making though primarily may be used in blender may also be used standalone (for cases where it wouldn’t interact with specific blender code). Like a browser for example. Furthermore some of the base classes used are used outside of blender as well.



I am also using QT (pyside2) to development a tool for Blender. The purpose is also to have it able to be stand-alone.
I am also facing the same problem in blender. The QT window cannot be parent / on top of the Blender. I tried the QT.WindowsStaysOnTopHint flag, it is not what I want as it freeze the blender out of the QT window.
Is there any solution you found and can share?

To keep your window on top of Blender, you can watch this little exemple that i wrote.
It’s for PySide2 but should work too with PyQt

import bpy

from bpy.types import Panel, Operator
from PySide2.QtCore import Qt, QEventLoop
from PySide2 import QtWidgets

class MyWindow(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(MyWindow, self).__init__(parent)
            self.windowFlags() ^ Qt.WindowStaysOnTopHint)


class PYSIDE_PT_tools_my_panel(Panel):
    bl_label = "Test Pyside"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'

    def draw(self, context):
        layout = self.layout
class PYSIDE_OT_display_window(Operator):
    '''  '''
    bl_idname = 'pyside.display_window'
    bl_label = "Display Window"
    bl_options = {'REGISTER'}

    def execute(self, context):
        = QtWidgets.QApplication.instance()
        if not
   = QtWidgets.QApplication(['blender'])

        self.event_loop = QEventLoop()

        self.widget = MyWindow()

        return {'FINISHED'}

CLASSES = [PYSIDE_OT_display_window, PYSIDE_PT_tools_my_panel]

def register():
    for cls in CLASSES:
def unregister():
    for cls in CLASSES:
if __name__ == "__main__":
1 Like

Will keep searching for How-To-Install-PySide for Blender.
Whether it is PyQt5 or PySide2 wouldn’t matter. PySide2 is preferred as a standard, and most common visual effects tools are PySide based. Along with seeing posts as above, where it is showing an instance of using PySide with Blender, hopefully there is a reliable method for installing PySide to use with Blender.

Is there a how-to for installing PySide2? And since most artists are not developers, hopefully it is as straight forward as the standard Python pip install.

Forgive if this is slightly off topic. Will look more to see if a similar topic is listed, and begin one if not.

Thank you very much for sharing your code. I have a question:
Do I need the QEventLoop() ? If I comment it the code still works. What is the purpose of the QEventLoop?