В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
Under-5 year old deaths dropped from 12.8 million (1990) to 4.8 million (2023). Neonatal deaths fell from 5.2 million to 2.3 million. Progress slowed since 2015. Most deaths happen in sub-Saharan Africa and Southern Asia. Main causes: infections, birth problems, and poor care. A baby in sub-Saharan Africa is 14 times more likely to die in the first month than one in Australia/New Zealand. 🌍👶@googlefactss#ChildHealth#GlobalHealth#SDG
Fergana Region, Fergana District, Mindonobod Neighborhood: We can’t breathe, please help!
Our homes are located near an asphalt plant, and due to its operations, dust and emissions enter our homes every day. If you step outside around 5–6 a.m., you can see the air is covered in haze. This situation seriously affects the health of our children: allergies and respiratory problems are increasing.
We have repeatedly submitted complaints through the clinic, neighbors, and other organizations, and sent letters to higher authorities, but no measures have been taken. The environmental agency has also failed to address the problem.
In addition, next to the asphalt plant, there are Megamix and Alibaster production facilities, whose emissions further worsen the air quality.
We are calling on the public and responsible authorities: please pay attention to this air pollution and the threat it poses to our children’s health, and take the necessary measures!
#Fergana#Mindonobod#Environment#AirPollution#ChildHealth#AsphaltPlant
☘️ Follow the latest environmental news on @ekologuz. Send your suggestions and feedback via @eklguz_bot.