PyQt Designer 在哪里写代码?
我安装了 PyQT v.4.8.8。当我绘制布局并想要查看代码时,它出现无法启动 uic 的错误,如快照中所示:
我可以在 cmdLine 中手动编译 .ui 文件。但我不知道在哪里放置插槽、方法、信号的代码。
1- 我应该在哪里设置查找 uic 来编译 ui 的设置?我的安装没有pyuic4。
2 - 我在哪里可以定义自己的插槽/方法和 functoins 签名? (接收者对象,发送者)我可以在编辑菜单中看到编辑信号/时隙,但只显示标准信号/时隙。没有定义您的信号/时隙的选项。
I have PyQT v.4.8.8 installed.When I draw layouts and I want to view the code , it comes with error that is unable to launch uic as in snapshot:
I can compile the .ui files manually in cmdLine. But I dont know where to put the code for slot,methods ,signals.
1- Where should I set the settings for finding uic to compile ui? My installation does not have pyuic4.
2 - Where can I define my own slots/methods and functoins signatures ? (receiver object,sender) I can see the Edit signals/slots in edit menu but that only shows standard signals/slots.Doesn't have options to define yours.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
顾名思义,Qt 设计器仅用于界面设计。您不能使用它来编写实际应用程序逻辑的代码。为此,您需要一个普通的 Python 编辑器。有关如何在 Python 中使用设计器文件的确切详细信息,请参阅 PyQt参考指南,使用 Qt Designer。
顺便说一句,
uic
不适用于 PyQt,而是用于将用户界面编译为 C++。要将用户界面编译为 Python,您需要使用pyuic4
。该工具无法从设计器运行,您需要手动运行。但建议使用PyQt4.uic
模块在运行时动态加载用户界面,如参考指南中所述。As the name says, the Qt designer is for interface design only. You cannot use it to write the code for the actual application logic. For this, you'll need a normal Python editor. The exact details on how to use designer files in Python are explained in PyQt reference guide, Using Qt Designer.
Btw,
uic
is not for PyQt, but for compiling user interfaces into C++. To compile user interfaces to Python, you need to usepyuic4
. This tool cannot be run from the designer, you need to run it manually. But it is recommended to load the user interface dynamically at runtime using thePyQt4.uic
modules as explained in the reference guide.我发现这个 PyQt4 的 教程 解释了如何在 Qt4 中添加您自己的插槽。信息非常丰富。
I found this tutorial for PyQt4 explaining how to add your own slots in Qt4.Very informative.