How to get the main window of the editor, to parent Qt or PySide application to it?

Hello, is this still valid for Unreal Engine 5? I tried this:

unreal.parent_external_window_to_slate(window.winId(), unreal.SlateParentWindowSearchMethod.ACTIVE_WINDOW)
print(window.parent())

when printing window parent → returns None
So after this the widget disappears, because there is no reference for it and garbage collector deletes it.

To partially fix this I can store my window widget into global variable, but that is not the best approach.

global ui
ui = window

Also it seems when storing widget into variable and then deleting it:

window.setParent(None)
window.close()
window.deleteLater()

It still stays in memory ( calling qt_app.allWidgets() returns increasing number of widgets). I know this has something to do with the fact that I am not calling qt_app.exec() ( this will make main loop for my window and freeze unreal which is unwanted behavior). Does anyone know how to remove widgets from the memory in unreal, or what will be the general approach?

1 Like