When we call the show() function of any PySide6 widget, the window content doesn’t display. Also, the close button at the top-right of the window is not working.
Image attached below.
Our dev environment is:
Rocky 9.8
GNOME desktop
X11 Windows system
[Attachment Removed]
Steps to Reproduce
We’re running the following python code:
#########################################
import sys
import unreal
from PySide6 import QtWidgets, QtCore
class SimpleUnrealTool(QtWidgets.QWidget):
def __init__(self, parent=None):
super().__init__(parent)
# Configure Window
self.setWindowTitle("Simple PySide6 Tool")
self.resize(300, 150)
# Create Layout and Content
layout = QtWidgets.QVBoxLayout(self)
label = QtWidgets.QLabel("Hello from PySide6!")
label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
layout.addWidget(label)
button = QtWidgets.QPushButton("Click Me")
button.clicked.connect(self.on_button_clicked)
layout.addWidget(button)
def on_button_clicked(self):
unreal.log("Button clicked inside PySide6 Tool Window!")
def main():
# 1. Ensure a QApplication instance exists (Unreal doesn't spin one up automatically)
app = QtWidgets.QApplication.instance()
if not app:
app = QtWidgets.QApplication(sys.argv)
# 2. Instantiate the tool widget
# Storing a global reference prevents Python's garbage collection from closing it immediately
global my_unreal_tool
my_unreal_tool = SimpleUnrealTool()
# 3. Parent the PySide6 window handle to Unreal Engine's Slate architecture
# This keeps the window pinned correctly to the editor active state
unreal.parent_external_window_to_slate(my_unreal_tool.winId())
# 4. Display the window
my_unreal_tool.show()
if __name__ == "__main__":
main()
#########################################
[Attachment Removed]
Hello,
UE/PySide integration is not supported on Linux. Nothing is running Qt’s event loop inside the Editor on Linux. On Windows, the editor’s message pump also delivers messages to Qt windows, so they paint and respond. On Linux/X11, Qt reads events from its own X connection, and only Qt’s event loop reads that connection. So your widget never gets its paint events or the close request. Also note that unreal.parent_external_window_to_slate()
only has an effect on Windows; on Linux it does nothing (See \Engine\Plugins\Experimental\PythonScriptPlugin\Source\PythonScriptPlugin\Private\PySlate.cpp:158)
That being said, I know that other people found alternative ways to use PySide. For example, see this other ticket:
The AI also proposed a fix. I didn’t test it, but it might be worth testing it:
---- AI Suggestion Begin ----
To fix it, pump Qt from the editor’s Slate tick instead of calling app.exec() (which would block the editor):
def _pump_qt(delta_seconds):
QtWidgets.QApplication.processEvents()
global qt_tick_handle
qt_tick_handle = unreal.register_slate_post_tick_callback(_pump_qt)
Register this once, right after creating the QApplication. The window should then paint, and the close button should work. If you want the tool to stay above the editor window, you can set the QtCore.Qt.Tool window flag on the widget.
---- AI Suggestion End ----
Please note that Qt/PySide integration isn’t an officially supported path on Linux. The supported way to add editor UI is Editor Utility Widgets:
Regards,
Patrick
[Attachment Removed]