如何在 Eclipse 中集成 PyQt 设计器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7036417/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 16:49:53  来源:igfitidea点击:

How to integrate PyQt designer in Eclipse?

eclipseqtpyqtqt-designerintegrate

提问by sunny2016

I'm trying to integrate the pydev, pyqt, python and eclipse. Now the code can be runing without error. And I know to make the GUI in Qt Designer. and then modified it in Eclipse.

我正在尝试集成 pydev、pyqt、python 和 eclipse。现在代码可以正常运行了。我知道在 Qt Designer 中制作 GUI。然后在Eclipse中修改它。

Now I want to integrate the Qt Designer of PyQt to Eclipse. Just like the Qt Eclipse Integration for C++. Use PyQt Designer in Eclipse. Can anybody teach me how to do it? Thanks very much!

现在我想将 PyQt 的 Qt Designer 集成到 Eclipse 中。就像 C++ 的 Qt Eclipse 集成一样。在 Eclipse 中使用 PyQt 设计器。有人可以教我怎么做吗?非常感谢!

BTW, I'm try to set the preference of qt project in Eclipse.

顺便说一句,我尝试在 Eclipse 中设置 qt 项目的首选项。

But when I add new qt version.I didn't know how to borrow the bin path. Because there is no bin path in PyQt.And also didn't have qmake,uic,rcc etc. the version name that I typed is PyQt-Py2.7-x64-gpl-4.8.5-1.exe. I borrow the include path like C:\python27\Lib\site-packages\PyQt4\Sib\PyQt4.

但是当我添加新的qt版本时,我不知道如何借用bin路径。因为PyQt中没有bin路径,也没有qmake、uic、rcc等,所以我输入的版本名称是PyQt-Py2.7-x64-gpl-4.8.5-1.exe。我借用了像 C:\python27\Lib\site-packages\PyQt4\Sib\PyQt4 这样的包含路径。

my OS is win7. Thanks for your answers! God bless you!

我的操作系统是win7。感谢您的回答!上帝祝福你!

采纳答案by Macke

The only way is to install the Qt Eclipse Integration, that way you can open ui files directly in eclipse.

唯一的方法是安装Qt Eclipse Integration,这样您就可以直接在 Eclipse 中打开 ui 文件。

But this does not work well with plugins and custom widgets, since that requires the exact same Qt version for the Eclipse integration and PyQt (and the same compiler flags..), and that may not be the case.

但这不适用于插件和自定义小部件,因为 Eclipse 集成和 PyQt 需要完全相同的 Qt 版本(以及相同的编译器标志......),而事实可能并非如此。

You could of course build the Qt Eclipse Integration yourself, if it works with the Qt version you're using with PyQt. (it's pre-built for 4.6.1, so it may or may not work with later Qt versions.)

您当然可以自己构建 Qt Eclipse 集成,如果它适用于您与 PyQt 一起使用的 Qt 版本。(它是为 4.6.1 预先构建的,因此它可能适用于也可能不适用于更高的 Qt 版本。)

What we've done is to tell Eclipse to open .ui files in Qt Designer outside of Eclipse. Not as nice, but it works with custom widget plugins, so it's a definite win for us.

我们所做的是告诉 Eclipse 在 Eclipse 之外的 Qt Designer 中打开 .ui 文件。不太好,但它可以与自定义小部件插件配合使用,因此对我们来说绝对是胜利。

回答by nomad

An easy way to open .ui files generated by Designer is to convert them to python code using "pyuic4" which comes with pyqt. On Windows and Linux (I haven't tested on Mac), open a shell and navigate to the directory containing your .ui file then run the command/flag/args... See example below:

打开 Designer 生成的 .ui 文件的一种简单方法是使用 pyqt 附带的“pyuic4”将它们转换为 python 代码。在 Windows 和 Linux 上(我没有在 Mac 上测试过),打开一个 shell 并导航到包含 .ui 文件的目录,然后运行 ​​command/flag/args...见下面的例子:

pyuic4 -o newOutputFile.py theOriginalPyQtFile.ui

pyuic4 -o newOutputFile.py theOriginalPyQtFile.ui

In the example my input file is called "theOriginalPyQtFile.ui" and the ouput file that will be generated is named "newOutputFile.py" and saved in the same directory as "theOriginalPyQtFile.ui".

在示例中,我的输入文件名为“theOriginalPyQtFile.ui”,将生成的输出文件名为“newOutputFile.py”并保存在与“theOriginalPyQtFile.ui”相同的目录中。

After that just open "newOutputFile.py" in Eclipse or any IDE.

之后,只需在 Eclipse 或任何 IDE 中打开“newOutputFile.py”。