在 PySide 中加载 QtDesigner 的 .ui 文件 [英] Loading QtDesigner's .ui files in PySide

查看:33
本文介绍了在 PySide 中加载 QtDesigner 的 .ui 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个简单的示例,说明如何将 QtDesigner 生成的 .ui 文件直接加载到 Python 应用程序中.

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

我只是想避免使用 pyuic4.

I simply would like to avoid using pyuic4.

推荐答案

PySide 与 PyQt 不同,实现了 QUiLoader 类直接读取 .ui 文件.来自链接的文档,

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()

这篇关于在 PySide 中加载 QtDesigner 的 .ui 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆