Pyqt5 简明教程
PyQt5 - What’s New
PyQt5 API 不会自动与早期版本兼容。因此,涉及 PyQt4 模块的 Python 代码应通过进行相关更改手动升级。在本章中,列出了 PyQt4 和 PyQt5 之间的差异。
PyQt5 API is not automatically compatible with earlier versions. Hence, Python code involving PyQt4 modules should be upgraded manually by making relevant changes. In this chapter, main differences between PyQt4 and PyQt5 have been listed.
v2.6 早期版本的 Python 不支持 PyQt5。
PyQt5 is not supported on versions of Python earlier than v2.6.
PyQt5 不支持 QObject 类的 connect() 方法用于信号与槽之间的连接。因此,不能再实现用法 −
PyQt5 doesn’t support connect() method of QObject class for connection between signal and slot. Hence the usage can no more be implemented −
QObject.connect(widget, QtCore.SIGNAL(‘signalname’), slot_function)
仅定义以下语法 −
Only the following syntax is defined −
widget.signal.connect(slot_function)
早期 QtGui 模块中定义的类已分布在 QtGui, QtPrintSupport 和 QtWidgets 模块中。
Classes defined in earlier QtGui module have been distributed in QtGui, QtPrintSupport an QtWidgets modules.
在新 QFileDialog 类的 getOpenFileNameAndFilter() 方法中, getOpenFileName(), getOpenFileNamesAndFilter() 由 getOpenFileNames() 和 getSaveFileNameAndFilter() 由 getSaveFileName() 替换。旧这些方法的签名也已发生更改。
In the new QFileDialog class, The getOpenFileNameAndFilter() method is replaced by getOpenFileName(), getOpenFileNamesAndFilter() by getOpenFileNames() and getSaveFileNameAndFilter() by getSaveFileName(). Older signatures of these methods also have changed.
PyQt5 无法定义一个从多个 Qt 类进行子类化的类。
PyQt5 doesn’t have provision to define a class that is sub-classed from more than one Qt class.
pyuic5 实用程序(用于从 Designer 的 XML 文件生成 Python 代码)不支持 --pyqt3-wrapper 标志。
pyuic5 utility (to generates Python code from Designer’s XML file) does not support the --pyqt3-wrapper flag.
pyrcc5 不支持 -py2 和 -py3 标志。pyrcc5 的输出与 v2.6 及以后版本的所有 Python 版本均兼容。
pyrcc5 does not support the -py2 and -py3 flags. The output of pyrcc5 is compatible with all versions of Python v2.6 onwards.
PyQt5 始终自动调用 sip.setdestroyonexit() 并调用它拥有的所有封装实例的 C++ 析构函数。
PyQt5 always invokes sip.setdestroyonexit() automatically and calls the C++ destructor of all wrapped instances that it owns.