Unable to Launch Qt uic

故事扮演 提交于 2019-12-04 08:21:49

Although you can certainly use Qt Designer for creating UIs for PySide/PyQt, you should be aware that it is primarily a C++ tool - it doesn't have any built in support for Python. So the "View Code..." command you refer to only produces C++ code - which is probably not much use to you if you intend using PySide or PyQt.

Qt Designer UI files are in an XML format (they usually have a .ui extension).

To use them with Python, there are basically two options:

  1. Load the .ui files directly into your application.
  2. Convert the .ui files into Python modules using an external tool.

There are several differences between PySide and PyQt in how these two options are implemented.

For PyQt, the full documention for both options can be found here.

For PySide, the documentation for option 1 can be found here - but it does not look like there is any documentation for option 2. However, the external tool for PySide (which is called pyside-uic) works very similarly to the one for PyQt (which is called called pyuic4).

If you need more general information about how to get started using Qt with Python, try the PySide Wiki or the PyQt Wiki.

If you were looking to generate python code, you would do this from the console. So, if you saved your file from the program as 'untitled', the default, run this:

 pyuic5 -m untitled.ui -o untitled.py

Making sure your working directory is the file location of 'untitled.ui'. It will then spit untitled.py into the same place.

To make

Form -> View code

work, directly from Qt Designer using either Qt4 or Qt5, you can just create a symbolic link from where Qt Designer is looking, pointing to where your pyuic5.exe executable is. With your example, it would be:

mklink /H "C:\Qt\4.8.2\bin\uic.exe" "C:\Python33\Lib\site-packages\PyQt4\pyuic4.exe"

Which is:

mklink /H "Path\to\uic.exe\file\Qt\designer\is\looking\for" "Path\to\actual\location\of\pyuic4.exe\or\pyuic5.exe\file"

Make sure the folder where "C:\Qt\4.8.2\bin\uic.exe" will reside exists obviously.

Just create a directory where it search for uic.exe file and copy existing uic.exe file to that directory.

My example : When I clicked View Code it shows Error asking for file uic.exe in path C:\python374\Lib\site-packages\pyqt5_tools\Qt\bin\bin

But I found uicexe file is in C:\python374\Lib\site-packages\pyqt5_tools\Qt\bin folder So I created another bin folder and copied uic.exe into that folder . That solved my problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!