首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >尝试将.ui文件转换为.py时,uic中缺少python生成器

尝试将.ui文件转换为.py时,uic中缺少python生成器
EN

Stack Overflow用户
提问于 2021-05-15 07:22:33
回答 1查看 57关注 0票数 1

我尝试使用uic file.ui -o file.py和其他组合将.ui文件转换为python文件,但是即使生成的文件是.py文件,其中的代码也是c++。在谷歌搜索和研究了一些uic前缀后,我注意到在我的uic --help菜单中,我只有java和cpp生成器,但在每个教程中,人们都有python|cpp生成器。

造成这种情况的原因可能是什么?如何解决?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-15 07:26:04

python的生成器已经在最新版本的Qt中引入,因此它可能在您的5.9.7版本的Qt中不可用,因此您必须安装更新的版本,例如,在我的示例中,我使用版本5.15.2:

代码语言:javascript
运行
复制
Usage: uic [options] [uifile]
Qt User Interface Compiler version 5.15.2

Options:
  -h, --help                    Displays help on commandline options.
  --help-all                    Displays help including Qt specific options.
  -v, --version                 Displays version information.
  -d, --dependencies            Display the dependencies.
  -o, --output <file>           Place the output into <file>
  -a, --no-autoconnection       Do not generate a call to
                                QObject::connectSlotsByName().
  -p, --no-protection           Disable header protection.
  -n, --no-implicit-includes    Disable generation of #include-directives.
  -s, --no-stringliteral        Deprecated. The use of this option won't take
                                any effect.
  --postfix <postfix>           Postfix to add to all generated classnames.
  --tr, --translate <function>  Use <function> for i18n.
  --include <include-file>      Add #include <include-file> to <file>.
  -g, --generator <python|cpp>  Select generator.
  --idbased                     Use id based function for i18n
  --from-imports                Python: generate imports relative to '.'

Arguments:
  [uifile]                      Input file (*.ui), otherwise stdin.

因此,现在我可以通过运行以下命令将.ui转换为.py:

代码语言:javascript
运行
复制
uic file.ui -o file.py -g python
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67541982

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档