How to parent Qt Widget under Unreal (UE5)

Hi, I’m struggling a bit with this, I want to implement a widget that behaves as a child of UE editor: the widget should always stay on top of UE (and only UE), and it should minimize as UE minimizes.

I looked into this topic a while back: How to get the main window of the editor, to parent Qt or PySide application to it?

I altered it a little so it looks like this, the window launches but it behaves like a standalone application, and the .parent() returns None

def main():
    global APP
    global WINDOW

    if not QtWidgets.QApplication.instance():
        APP = QtWidgets.QApplication(sys.argv)

    exists = WINDOW is not None

    if not exists:
        WINDOW = Example()
        unreal.parent_external_window_to_slate(
            WINDOW.winId().__init__(),
            unreal.SlateParentWindowSearchMethod.MAIN_WINDOW
        )

    WINDOW.showNormal()

    unreal.log_warning(
        "What is {}'s parent?  {}".format(WINDOW.winId(), WINDOW.parent()))
    return WINDOW

Am I doing something wrong? is this unreal.parent_external_window_to_slate outdated (unreal — Unreal Python 5.0 (Experimental) documentation)?

It is working for me. You have to add the command after the window is shown otherwise it is not working.

if __name__ == "__main__":
    if not QApplication.instance():
        app = QApplication(sys.argv)
    else:
        app = QApplication.instance()

    window = MainWindow()
    winid = window.winId()

    window.show()
    unreal.parent_external_window_to_slate(window.winId())
1 Like

Thanks, this was it!!!