PyQt 信号和槽
我刚刚开始使用 PyQt 进行编程,并且正在关注 Mark Summerfield 的“Python 和 Qt 中的快速 GUI 编程”。在此之前,我用 C++ 和 Qt 进行了一些编程,我遵循的书的作者推荐使用信号和槽,而且我也喜欢使用信号和槽而不是“on_widgetName_signalName”方法。但我很惊讶地看到“Python 和 Qt 中的快速 GUI 编程”的作者在使用设计器创建 GUI 的任何地方都在信号和插槽上使用了“on_widgetName_signalName”,更令我惊讶的是与 pyqt 捆绑在一起的示例安装程序做同样的事情。
是否有理由在 PyQt 中的信号和插槽上使用“on_widgetName_signalName”方法,或者只是这些人很长时间没有更新他们的代码?
I've just started programming in PyQt and I'm following "Rapid GUI programming in Python and Qt" by Mark Summerfield. Before this I did some programming in C++ and Qt and the author of the book which I followed recommended the use of signals and slots, and I too like the use of signals and slots over "on_widgetName_signalName" methods. But I was surprised to see that the author of "Rapid GUI programming in Python and Qt" uses "on_widgetName_signalName" over signals and slots wherever he created GUI using designer, and I was even more surprised to see that the examples which comes bundled with pyqt installer doing the same.
Is there a reason to use "on_widgetName_signalName" method over signals and slots in PyQt or its just that these people have not updated their code for long?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,当您使用 on_widget_signal() 时,它会自动将“widget”的信号连接到该函数(适用于 C++)
检查 QMetaObject::connectSlotsByName
Basicly when you use on_widget_signal() it auto connects "widget"'s signals to that function (applies to C++)
Check QMetaObject::connectSlotsByName