我尝试使用uic file.ui -o file.py
和其他组合将.ui文件转换为python文件,但是即使生成的文件是.py文件,其中的代码也是c++。在谷歌搜索和研究了一些uic前缀后,我注意到在我的uic --help菜单中,我只有java和cpp生成器,但在每个教程中,人们都有python|cpp生成器。
造成这种情况的原因可能是什么?如何解决?
发布于 2021-05-14 23:26:04
python的生成器已经在最新版本的Qt中引入,因此它可能在您的5.9.7版本的Qt中不可用,因此您必须安装更新的版本,例如,在我的示例中,我使用版本5.15.2:
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:
uic file.ui -o file.py -g python
https://stackoverflow.com/questions/67541982
复制相似问题