Jack Lilhammers
Jack Lilhammers

Reputation: 1247

Is it possible to choose at runtime to import uic compiled files or dynamically load the ui with QUiLoader()?

As stated in the official documentation there are 2 ways of importing .ui files in your code:

In my project I'm using Option A, but now I'm wondering if it would be possible to choose at a project level Option A or Option B at runtime, because it would avoid having to compile the widgets after each change while in development

Upvotes: 0

Views: 133

Answers (1)

eyllanesc
eyllanesc

Reputation: 244282

In the case of Qt for Python the option is to use loadUiType:

ui_class, qt_class = loadUiType("filename.ui")

class FooWidget(QFooWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = ui_class()
        self.ui.setupUi(self)

Upvotes: 2

Related Questions