В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🚗💨Toyota Unveils GR86 Inspired by the Iconic Celica at SEMA!🎉
Introducing a stunning blend of three legends: the modern GR86 coupe, the dynamic GR Corolla hatch, and the legendary rally warrior, the Celica GT-Four from the late '80s! 🏁✨
Under the hood, the GR86 is powered by a 300-hp 1.6L turbocharged inline-three from the GR Corolla, paired with an all-wheel-drive system featuring a rear differential! 🔥🔧
Inside, it’s all about performance with sporty bucket seats and a safety roll cage, while the exterior pays homage to the famous rally car. 🏆🏎️
#Toyota#GR86#Celica#SEMA2023#CarEnthusiast#RallyLegend#PerformanceCars#Auto🚘💖
🚗💨Introducing the Doughboy: A Mind-Blowing Restomod with 2838 HP!💥
At the SEMA Show, we unveiled a beast that redefines power and performance! 🔥 This incredible V8 engine boasts a staggering 8.8 liters of displacement and is equipped with dual turbochargers, pushing the limits of automotive engineering. 💪✨
🔧 With the engine strategically shifted 40 cm back towards the center of the wheelbase, every detail has been meticulously crafted from scratch, including the intake, exhaust, and cooling systems. 🛠️
💎 Custom parts were expertly created using CNC machining and 3D printing technology, showcasing innovation at its finest.
Get ready to experience the future of restomods! 🚀
#Doughboy#SEMA2023#Restomod#V8Power#Turbocharged#CarEnthusiast#AutomotiveInnovation#CustomCars#CNC#Auto