PySide and Unreal5

Hello,
Im currently investigating how to use pyside from within unreal5, as far as I can tell and based on my research it’s doable but somehow I can’t call any QtWidgets objects without crashing the editor.

I installed PySide 2 and Pyside6 using the ue5 pip utility and I can import both module successfully but as soon as I do something like QtWidgets.QDialog() the editor straight up crash :confused:

Has anyone from here managed to resolve this ?

Haven’t tried UE5 yet but in 4 it’s possible, as long as you initialise your own QApplication before creating any widgets (so pretty normal for Qt)

Getting them to interact any more deeply has been much more trouble, and usually not worth it for what you need. You can connect a python update function to the editor’s tick signal, but that has a habit of crashing too

1 Like

Ah yeah that was it, thanks :slight_smile: so far it’s mainly for experimenting ideally I’d like to check if I can share the same UI between ue5 and other dcc but like you said maybe it’s not worth it.

I do our UI’s in UE5/PySide/Python3, no issues. Sounds like you solved it, but it’s been bullet proof so far for our production.

Sharing the same UI between DCC’s is ‘technically doable’, but I’ve yet to find a reason, got an example?

We share UI’s between DCCs at work. We even have a translation layer so we can run basic commands cross-dcc.

The UI part is easy. However the cross DCC part has some issues. It accumulates a LOT of technical debt over time, it takes a lot of work to set up, and the naming convention is all over the place. But having a UI and basic functions up and running with minimal work is great for being able to use the best tools for the job.

1 Like

One good use for this is integration with an abstract asset system - it’s been a massive help to artists to have one common widget to display the name of the current asset (character, costume etc) without needing to worry about navigating dcc-specific file structures to find what they need.

If you have the same UI across Maya, Substance and Unreal, all those UIs can display “character: hero1” and you know that all your work is going to the same destination

You might be interested in https://github.com/hannesdelbeke/unreal_qt
it sets up a qt env in unreal (5) with PySide2
and also handles some additional kinks like matching the UI style using qt stylesheets, and taking care of garbage collection for you so you dont need to handle references to your widgets manually

it works quite well, I combine it with https://github.com/hannesdelbeke/unimenu to create a unreal menu to launch qtwidgets, all in pure python so no compiling needed. with the added benefit that tools often work in both unreal 4 and 5 without additional work.

2 Likes

I’m trying this out at the moment. Nice work!
But I’m getting an issue with connecting the close event:

LogPython: Error:     widget.close.connect(lambda: cls.remove_window(widget))
LogPython: Error: AttributeError: 'builtin_function_or_method' object has no attribute 'connect'

Not sure why that’s happening!

Edit: I commented out the second definition of widget_manager, and I’m getting something that works. The only issue I have is that the tool window won’t stay on top of the Unreal main window. I can live with that until I find a solution. Again, thanks… nice work!

I mean … the error says what’s happening. The function .close doesn’t have a .connect. Which makes sense because .close isn’t a signal. It’s a slot :slight_smile:

Looking at what you’re doing, I think you want to override the method named closeEvent on your widget subclass. The docs say that method will automatically get called when the widget is closing, and you can have it run your remove_window classmethod.

https://doc.qt.io/qt-5/qwidget.html#closeEvent