# PyQt 使用Qt Designer ui文件

- URL: https://www.yidoo.xyz/pyqt-with-qt-designer-ui-files
- 作者: 核动力蜗牛
- 发布时间: 2010-07-31
- 更新时间: 2010-07-31
- 分类: 技术笔记
- 标签: qt, python, pyqt

首先用 Qt Designer 创建窗体后，保存为 form.ui

然后再 cmd 中输入

```python
pyuic4 -o ui_form.py form.ui
```

之后对应目录下生成 ui_form.py 的文件

附上 pyuic4 的帮助

```python
NAME
       pyuic4 - compile Qt4 user interfaces to Python code
SYNOPSIS
       pyuic4 [OPTION]... FILE
DESCRIPTION
       pyuic4  takes  a Qt4 user interface description file and compiles it to
       Python code. It can also show a preview of the user interface.
OPTIONS
       -h, --help
              Show a summary of the options.
       --version
              Display the version number of pyuic4 of the version of Qt  which
              PyQt4 was generated for.
       -p, --preview
              Show a preview of the UI instead of generating Python code.
       -o, --output=FILE
              Write the generated Python code to FILE instead of stdout.
       -d, --debug
              Show  detailed  debugging  information  about  the UI generation
              process.
       -x, --execute
              Generate extra code to test and display the class when  executed
              as a script.
       -i, --indent=NUM
              Set the indentation width to NUM spaces. A TAB character will be
              used if NUM is 0 (default: 4).
```
