В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
Satellite images from October 24, 2024, reveal the destruction in #SouthernLebanon, where villages like Kfar Kila and Blida now lie in ruins, caused by Israeli strikes in the area.
#Lebanon#Israel#MiddleEast#Gaza#LebanonUnderAttack
As the 60-day ceasefire deadline ended, the people of southern #Lebanon returned to their homes despite Israeli violence. 15 martyrs and 83 injured in the ongoing struggle for their land.
#DayOfReturn#CeasefireDeadline#Resilience#Israel#SouthernLebanon#Occupation
After over a year of displacement, the people of southern #Lebanon return—not to homes, but to the land scarred by Israeli aggression. Their spirit is unbroken.
#Resilience#SouthernLebanon#ReclaimingHome#Rebuilding#Israel#LebaneseArmy
🚀 Israeli Military Strikes Over 200 Hezbollah Targets in Lebanon
The Israeli Defense Forces announced on April 11 that they have conducted airstrikes on more than 200 targets in Lebanon over the past day. According to BlockBeats, all targets were associated with the Iran-backed terrorist organization Hezbollah. Video footage released shows a building exploding after an aerial attack, while another video captures a similar scene from a distance. The Israeli Defense Forces did not provide further details regarding these videos.
The military stated that its air force continues to target infrastructure linked to Hezbollah. Additionally, the forces are assisting ground troops in southern Lebanon to combat launch sites and prevent artillery fire aimed at Israeli citizens.
#IsraeliMilitary#Hezbollah#Lebanon#Airstrikes#IDF#Iran#TerroristOrganization#GroundTroops#SouthernLebanon#ArtilleryFire#IsraeliCitizens