Search code examples
pythonqtpyside

Loading QtDesigner's .ui files in PySide


I am looking for a simple example of how to directly load a QtDesigner generated .ui file into a Python application.

I simply would like to avoid using pyuic4.


Solution

  • PySide, unlike PyQt, has implemented the QUiLoader class to directly read in .ui files. From the linked documentation,

    loader = QUiLoader()
    file = QFile(":/forms/myform.ui")
    file.open(QFile.ReadOnly)
    myWidget = loader.load(file, self)
    file.close()