Thanks!

After modifying the stackoverflow code to work with PySide2, it works fine for displaying a QMessageBox. For any QWidget derived item, the application crashes upon trying to draw it (so immediately), deep inside painting code.

Qt Code:
  1. from PySide2.QtWidgets import QApplication, QLabel, QMessageBox, QPushButton
  2.  
  3. all_widgets = QApplication.instance().allWidgets()
  4. window = None
  5. for widget in all_widgets:
  6. if str(widget.objectName()) == "main_window":
  7. window = widget
  8. break
  9.  
  10. //works
  11. QMessageBox.information(window, 'Test', 'Hello!', QMessageBox.Ok)
  12.  
  13. //crash during paint
  14. label = QLabel("<font color=red size=40>Hello World!</font>")
  15. label.setParent(window)
  16. label.show()
To copy to clipboard, switch view to plain text mode 


backtrace: https://pastebin.com/d3qTSgef


Smells a bit like a use-after-free, maybe there is an issue with having to specify that I take ownership of the widget or something ...

Thanks again