В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🌎 Vampire squid live more than 2,000 meters below the ocean’s surface, where sunlight never reaches. This deep-sea animal uses long, webbed arms and blue bioluminescent light to confuse predators. Vampire squid can survive with very little oxygen, thriving in one of the planet’s most extreme habitats. ✨
#oceanlife⚡#deepsea⚡#animals
👉subscribe Interesting Planet
👉more Channels
🌎 Giant isopods, distant relatives of the common pillbug, inhabit the deep ocean at depths exceeding 500 meters. These armored scavengers can reach up to 50 centimeters in length, surviving on the remains of dead sea animals that sink to the seafloor. ✨
#oceanlife⚡#deepsea⚡#biodiversity
👉subscribe Interesting Planet
🌎 The Pompeii worm thrives on underwater volcanoes, enduring temperatures near 80°C. Its furry back hosts heat-loving bacteria, forming a living protective shield in extreme ocean heat. ✨
#oceanlife⚡#extremophiles⚡#discovery
👉subscribe Interesting Planet
🪐 One of the most surprising places where scientists think life could exist is Jupiter’s moon Ganymede, which hides a deep, salty ocean beneath its thick icy crust. Data from the Galileo spacecraft revealed Ganymede’s magnetic field wobbles in a way best explained by a vast liquid ocean, making this giant moon a real candidate for life far from the warmth of the Sun. ✨
#Ganymede⚡#oceanlife⚡#habitableworlds⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🐙Oscar-Winning My Octopus Teacher – A Deep Dive into Unlikely Friendship
🇿🇦 Burnt out and emotionally drained, filmmaker Craig Foster found healing in the ocean off Cape Town.
Over eight years, he formed an extraordinary bond with a wild octopus — a creature that became his unexpected teacher.
🎬My Octopus Teacher (2021) is a beautifully shot documentary about connection, balance, and rediscovering the natural world.
🏆 The film won the Oscar and BAFTA for Best Documentary Feature — a must-watch for nature lovers and seekers of meaning.
📽Official trailer (with Russian subtitles):
🔗https://www.youtube.com/watch?v=yP-dgd852Ro
#MyOctopusTeacher#Documentary#NatureFilm#OceanLife#CapeTown#SouthAfrica#OscarWinner#BAFTA#Wildlife#Diving#Mustwatch