В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🚨 A Palestinian youth, Alaa Khaled Sbeih, was martyred after being shot by settlers during confrontations in the vicinity of a settlement outpost near the village of Tayasir, east of #Tubas.
Glory to the martyrs.
🚨 Smoke is rising in the air in #Tubas after resistance fighters targeted invading zionist forces with an explosive device during the fierce armed clashes taking place in the city.
In continuation of its service to the zionist occupation, the forces of the Palestinian Authority open fire during their abduction of freed prisoner Saeed Siyajat in #Tubas.
Heeding to the calls of the resistance and in protest of the persecution of the resistance at the hands of the Security Forces who continue to bow to the demands of the occupation, as well as to denounce the arrest of the fighter Ahmed Abu Al-Aida, young men close streets in downtown #Tubas.
🚨 A Palestinian youth, Alaa Khaled Sbeih, was martyred after being shot by settlers during confrontations in the vicinity of a settlement outpost near the village of Tayasir, east of #Tubas.
Glory to the martyrs.
Israeli military's extensive West Bank operation kills at least nine Palestinians, imposes severe restrictions, and blocks medical access.
#NewsUpdate#WestBankOperation#Israel#Jenin#Tulkarm#Tubas#Nablus#Gazawar#MiddleEast