В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🌍 Some savannas and grasslands support massive termite mounds reaching over 8 meters high. These structures regulate temperature and moisture, acting as tiny skyscrapers for entire insect communities. ✨
#savanna⚡#grassland⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 In South America’s Cerrado grassland, more than 4,800 plant species are found only there. This savanna rivals the Amazon in biodiversity but is rapidly disappearing to farmland. ✨
#savanna⚡#grassland⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Some African savannas are home to "whistling thorn" trees, which grow hollow spines. Tiny ants live inside and defend the tree from animals, forming a team-up rarely seen in grassland ecosystems. ✨
#savanna⚡#grassland⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Tropical savannas can burn naturally every 1–3 years, yet some species, like the baobab tree, thrive by storing water in thick trunks to survive both drought and fire. ✨
#savanna⚡#grassland⚡#adaptation⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Seasonal fires in some savannas are so regular that certain plants have evolved to flower or sprout only after being scorched, using fire as a natural part of their life cycle. ✨
#savanna⚡#grassland⚡#fire⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Some grassland fires are started by lightning and play a natural role in shaping these ecosystems. Fire clears old growth, helps seeds sprout, and maintains open habitat for many animals. ✨
#savanna⚡#grassland⚡#fire⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍