Omniverse Create and Qt

Are there any guidelines on integrating Qt with the Create?
I’ve managed to show a Qt window from Create on certain event but after showing/closing it for several times Create get frozen.
Are there any docs describing event loop/run loop of the python in the Create?

I don’t think we have any guidance on this currently, but let me confirm.

I’ve confirmed that we don’t currently support this.

I thought I’d offer a potential solution for the blocked UI issue that you ran into. You can’t call QApplication.exec_()because it blocks Create’s UI thread. Instead, you need to let Create drive the Qt updates by hooking into Create’s event loop.

import carb.events
import omni.kit.app

from PySide2.QtCore import QSize, Qt
from PySide2.QtWidgets import QApplication, QMainWindow, QPushButton

update_stream = omni.kit.app.get_app().get_update_event_stream()


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        button = QPushButton("Press Me!")
        button.clicked.connect(self.button_clicked)
        self.setCentralWidget(button)
        
    def button_clicked(self):
        print("Clicked!")

try:
    app = QApplication([])
except:
    app = QApplication.instance()

window = MainWindow()
window.show()

def on_update(e: carb.events.IEvent):
    app.processEvents()

sub = update_stream.create_subscription_to_pop(on_update, name="My Subscription Name")
2 Likes

Thank you. Indeed calling exec_() is wrong.
Tried hooking to update event stream.
It works and I routed update events to app.processEvents()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.