В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
#Ebola Virus Disease (EVD) has a high fatality rate, but early detection, supportive care, and strict adherence to preventive measures can significantly reduce risks.
⚠️ Protect yourself and others by following health advisories, practicing good hygiene, and reporting any suspected cases immediately.
#EbolaAwareness#HealthyLiving#NCDCNigeria
#Ebola is a serious infectious disease that can spread rapidly if not recognized and contained on time. The signs and symptoms usually appear 2–21 days after exposure.
⚠️ If you or someone around you notices these symptoms, do not ignore them. Seek medical attention immediately and avoid contact with others until cleared by health professionals.
🛡️ Protecting yourself also protects your family, friends, and community.
Let’s work together to stop the spread of Ebola.
#EbolaAwareness#HealthyLiving#StaySafe
#Ebola is caused by the Ebolavirus — a group of viruses with several species, including Zaire, Sudan, Bundibugyo, Taï Forest, and Reston ebolavirus (which affects animals but not humans).
Knowing the cause helps us strengthen prevention and response efforts. 💪🏾
Stay Safe, Stay Protected!
#EbolaAwareness#HealthSecurity#NCDCNigeria