【问题标题】:Is it possible to choose at runtime to import uic compiled files or dynamically load the ui with QUiLoader()?是否可以在运行时选择导入 uic 编译文件或使用 QUiLoader() 动态加载 ui?
【发布时间】:2021-09-12 14:26:06
【问题描述】:

official documentation 中所述,有两种方法可以在您的代码中导入.ui 文件:

在我的项目中,我正在使用选项 A,但现在我想知道是否可以选择 在项目级别选项 A 或选项 B 在运行时,因为它可以避免在开发过程中每次更改后都必须编译小部件

【问题讨论】:

    标签: python qt pyside2


    【解决方案1】:

    在 Qt for Python 的情况下,选项是使用 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)
    

    【讨论】:

    • 谢谢,我需要在我正在制作的包装中使用它
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多