В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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 Update: Gaza Humanitarian Crisis 🚨
WHO warns of a "death sentence" for vulnerable hospital patients in Gaza due to Israel's evacuation order. Moving them within 24 hours is impossible and inhumane. UN calls it "impossible" and EU diplomat calls it "utterly unrealistic". Hospitals are at breaking point, with limited electricity and critical shortages. Time is running out to prevent a catastrophe. Urgent delivery of supplies and a humanitarian corridor needed. #SaveGaza#HumanitarianCrisis
https://www.aljazeera.com/news/2023/10/13/israels-evacuation-order-for-gaza-death-sentence-for-patients-who-says
Subscribe to @BadVolfNews
🚨GENOCIDE ALERT🚨 Gaza is being subjected to a horrifying campaign of violence. Over 11,000 dead, including 1,400 children. Hospitals and schools targeted. Palestinians denied access to basic necessities. This is genocide. We must recognize the humanity of the Palestinian people and demand an end to this atrocity. #SaveGaza#EndGenocide
https://www.aljazeera.com/opinions/2023/11/12/genocide-in-gaza-a-call-for-urgent-global-action
Subscribe to @BadVolfNews
🔻 Gaza Strip: A graveyard for children. UN warns of more deaths due to dehydration amid Israel's relentless attacks. Over 8,500 Palestinians, mostly children and women, killed. Shocking figures reveal 420 children killed or injured daily. Ceasefire and humanitarian aid urgently needed. Water crisis and trauma pose additional threats. Mental health support desperately required for over 800,000 children. Collateral damage? No safe place in Gaza. International attention needed! #SaveGaza#ChildrenUnderAttack
https://www.aljazeera.com/news/2023/10/31/gaza-has-become-a-graveyard-for-thousands-of-children-un
Subscribe to @BadVolfNews