В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🌎 The axolotl, a salamander native to Mexico, can regenerate entire limbs, spinal cord, heart tissue, and even parts of its brain. Unlike most amphibians, axolotls remain aquatic and gilled for their whole lives due to a trait called neoteny. ✨
#axolotl⚡#regeneration⚡#amphibians
👉subscribe Interesting Planet
👉more Channels
🌎 The axolotl, native to Mexico’s lakes, can regrow lost limbs, parts of its heart, and even sections of its brain. This “walking fish” stays forever young, never fully transforming into adulthood—a rare phenomenon called neoteny. ✨
#axolotl⚡#regeneration⚡#neoteny
👉subscribe Interesting Planet
Hydra, a tiny freshwater animal, can theoretically live forever if nothing eats or kills it. They don't age because they keep regenerating cells.
🧬
[Read more]
@googlefactss#Hydra#Immortal#Regeneration#Science
Axolotls, also known as Ambystoma mexicanum, get their name from the Aztec language Nahuatl, meaning "water monster" or "water god." According to legend, they are the earthly form of Xolotl, the Aztec god who transformed into a salamander to avoid sacrifice. These creatures are famous for regenerating limbs, hearts, and even parts of their brains. They stay in their juvenile form for life, a trait called neoteny. In the wild, axolotls are critically endangered, with fewer than 1,000 left in Mexico’s Xochimilco and Chalco lakes. Habitat loss, pollution, and invasive species like tilapia are major threats. Conservation efforts are underway to restore their habitat and protect them from extinction.
🦎🌍💧
[Read more]
If you have one as a pet, feel free to share with us!
@googlefactss
#Axolotl#WaterGod#EndangeredSpecies#Regeneration#Neoteny#Conservation#Wildlife#Mexico#Amphibians