В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль QtCompat (compatibility). Там не так много функций но они довольно полезны.
Этот модуль содержит унификаци модуля shiboken2, функций loadUi, translate и несколько переименованных функций классов или изменённую сигнатуру аргументов и возвращаемых значений. Это единственное исключение из правила когда вам потребуется где-то изменить свой код кроме импортов и этот код не похож на обычный код PySide2.
Например, в PyQt4 и PySide есть метод
QHeaderView.setResizeMode
Для PyQt5 и PySide2 они были благополучно переименованы в
QHeaderView.setSectionResizeMode
Чтобы применить этот метод следует использовать такой код
from Qt import QtCompath
header = self.horizontalHeader()
QtCompat.QHeaderView.setSectionResizeMode(header, QtWidgets.QHeaderView.Fixed)
Унификация загрузки UI файлов:
# PySide2
from PySide2.QtUiTools import QUiLoader
loader = QUiLoader()
widget = loader.load(ui_file)
# PyQt5
from PyQt5 import uic
widget = uic.loadUi(ui_file)
# Qt.py
from Qt import QtCompat
widget = QtCompat.loadUi(ui_file)
Хорошо что таких моментов не много и их легко запомнить.
Полный список можно посмотреть в таблице.
#qt#tricks
Roberto Morales Ojeda en Facebook
Sostuve esta tarde, un fraternal encuentro con Liu Jie, vicesecretario del Comité Provincial del Partido Comunista de #China y gobernador de #Zhejiang.
Ratifiqué la voluntad de continuar fortaleciendo los excelentes vínculos interpartidistas.
https://www.facebook.com/share/p/195yVe7e8D/
#China executes 11 gang members who lured #Kenyans to #Myanmar scam compounds
China has executed 11 members of a criminal gang convicted of luring foreigners—including Kenyans—into scam compounds in Myanmar, where they ran a billion-dollar online fraud and illegal gambling network.
The criminal syndicate was convicted of running a vast online fraud and illegal gambling operation that generated more than $14 billion, according to state media and court records.
The executions approved by China's Supreme Peoples Court and carried out in eastern #Zhejiang province underscore Beijing' intensifying crackdown on transnational crime networks operating across Southeast Asia, These networks have increasingly affected victims and financial systems far beyond the region including in Africa.
Chinese authorities said the defendants were key figures in the so-called Ming family criminal group .....
https://web.facebook.com/AddisstandardEng/posts/pfbid0Txiw6s8otRMFRWz7hk7ioaecYZkBNx1cMqVXPy67uL3pPMJaJZA2fGQyqs8aymkSl