В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🚨 Urgent Call for Ceasefire in Gaza 🚨
USAID staff demand immediate end to violence, decrying civilian deaths and violations of international law. Aid efforts futile amidst indiscriminate bombing. Gaza needs more than just aid, it needs the bombs to stop. Pressure mounts on US government to take action, hold all parties accountable. UN warns of grave risk of genocide. Meanwhile, US continues unwavering support for Israel, providing billions in military aid. Will Congress break the silence? #CeasefireNow#GazaCrisis
https://www.aljazeera.com/news/2023/11/8/more-than-1000-usaid-employees-sign-letter-backing-gaza-ceasefire
Subscribe to @BadVolfNews
UN chief warns of "immense suffering" as Gaza aid remains inadequate. Israel's relentless bombardment overwhelms hospitals and leaves Gaza without essential supplies. More than 8,500 lives, including children, have been lost. The situation is "absolutely horrific", says Red Crescent. Calls for a ceasefire and increased humanitarian aid are rejected by the US, prioritizing their support for Israel. As the death toll rises, the UN pleads for an end to this "spiral of death". The world must act now to prevent further tragedy. #GazaCrisis#HumanitarianAid
https://www.aljazeera.com/news/2023/10/31/un-chief-guterres-says-aid-trickling-into-gaza-is-completely
Subscribe to @BadVolfNews
⚠️ Update: US officials report 17 Americans missing amidst Israel-Hamas war. Death toll of US citizens rises to 22. Hostages held by Hamas confirmed, but numbers are unclear. US Secretary of State Blinken warns death toll could increase. US military deploys second aircraft carrier. Israeli blockade intensifies, cutting off supplies to 2.3 million Palestinians. Nonstop Israeli air raids devastate Gaza, killing over 1,055 people. Efforts underway to secure safe passage for civilians. Victims caught in the crossfire. #IsraelHamasWar#GazaCrisis
https://www.aljazeera.com/news/2023/10/11/us-death-toll-in-israel-hamas-war-rises-to-22-officials
Subscribe to @BadVolfNews
Eva Bartlett @Reality_Theories talks about how Israeli policies have turned Gaza into a disaster zone, fostering starvation and disease.
Full episode: https://youtu.be/ntHkkCGyfdo
#GazaCrisis#IsraeliPolicies#EvaBartlett#MiddleEast#Israel#Palestine