В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🌎 In Papua New Guinea, the Korowai people still build treehouses perched up to 35 meters above ground. This tradition began as a way to avoid floods, wild animals, and rival clans. Some Korowai treehouses even have separate “guest” platforms for visitors or ritual gatherings. ✨
#anthropology⚡#traditions⚡#rituals
👉subscribe Interesting Planet
👉more Channels
🌎 In Vanuatu, the Naghol or "land diving" ritual involves men jumping from tall wooden towers with vines tied to their ankles. This dangerous tradition, practiced on Pentecost Island, is meant to ensure a good yam harvest. Some platforms are over 20 meters high, and proper vine length is crucial to prevent injury. ✨
#traditions⚡#anthropology⚡#rituals
👉subscribe Interesting Planet
👉more Channels
🌎 In Spain’s Catalonia region, families celebrate Christmas with the “Caga Tió,” or “pooping log.” Children decorate a wooden log with a face, cover it with a blanket, and “feed” it every night. On Christmas Eve, they beat the log with sticks while singing a traditional song, and small gifts and sweets are found underneath the blanket. The custom dates back at least to the 18th century. ✨
#traditions⚡#rituals⚡#culture
👉subscribe Interesting Planet
👉more Channels
🌎 In the Indonesian village of Trunyan, the dead are laid out on the ground and covered with bamboo cages instead of being buried. The local Taru Menyan tree releases a natural fragrance that masks odors, allowing bodies to decompose above ground without attracting scavengers. ✨
#rituals⚡#anthropology⚡#Indonesia
👉subscribe Interesting Planet
👉more Channels