В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🌎 Glowing deep-sea animals like the comb jellyfish and dragonfish create their own light using bioluminescence. This adaptation helps them hunt, attract mates, or avoid predators in pitch-black ocean depths. Some dragonfish possess "invisible" red bioluminescence, seen only by their own kind, for stealthy communication. ✨
#ocean⚡#animals⚡#bioluminescence
👉subscribe Interesting Planet
👉more Channels
🌍 The Waitomo Glowworm Caves in New Zealand are famous for thousands of tiny insects that light up the darkness, creating a galaxy-like effect in this unique karst underground world. ✨
#caves⚡#karst⚡#bioluminescence⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌎 Shrouded in darkness, the “midnight zone” of the ocean lies below 1,000 meters, where sunlight can’t reach and pressure crushes like a dozen elephants. Creatures here glow with bioluminescence and withstand freezing cold, revealing how life adapts to our planet’s most mysterious depths. ✨
#ocean⚡#bioluminescence⚡#deepsea
👉subscribe Interesting Planet
🌎 Lightning bugs, or fireflies, create their glow through a special enzyme called luciferase. This reaction produces cold light, wasting almost no energy as heat—a marvel of natural engineering for nighttime signaling. ✨
#bioluminescence⚡#insects⚡#nature
👉subscribe Interesting Planet
🌎 Glowing tides known as bioluminescent bays light up in places like Puerto Rico. Microorganisms called dinoflagellates produce blue-green light when stirred by waves or movement. The brightest, Mosquito Bay, can host up to 700,000 glowing organisms in just one liter of water. ✨
#bioluminescence⚡#ocean⚡#phenomenon
👉subscribe Interesting Planet
👉more Channels
🌍 Some coasts shine with glowing “blue waves” at night, caused by tiny plankton called dinoflagellates emitting light when disturbed—a dazzling phenomenon known as marine bioluminescence. ✨
#seas⚡#coastline⚡#bioluminescence⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌎 Glowing waves known as “sea sparkle” can light up coastlines at night. This effect is caused by bioluminescent plankton emitting blue light when disturbed. Some blooms stretch for kilometers and are most often seen in warm coastal waters. ✨
#bioluminescence⚡#ocean⚡#plankton
👉subscribe Interesting Planet
👉more Channels
🌎 Glowing waves sometimes light up the ocean at night thanks to bioluminescent plankton. These tiny marine organisms emit blue light when disturbed, turning shorelines into breathtaking, natural light shows. ✨
#ocean⚡#bioluminescence⚡#plankton
👉subscribe Interesting Planet
🌎 The vampire squid thrives in the ocean’s dark depths by using bioluminescent light organs to confuse predators. Its name comes from its cloak-like webbed arms, not from blood-drinking. ✨
#ocean⚡#cephalopod⚡#bioluminescence
👉subscribe Interesting Planet
🌎 In the Mediterranean Sea, the bearded fireworm boasts bristly, glowing spines that can cause a painful sting. This marine worm’s bioluminescence warns predators while its venomous bristles deter unwelcome touches—a perfect example of nature’s flashy, double-edged defense system. ✨
#fireworm⚡#bioluminescence⚡#ocean
👉subscribe Interesting Planet
🌎 Somewhere in the world’s oceans, the “milky sea” phenomenon can make water glow bright blue for up to several days. Caused by massive colonies of bioluminescent bacteria, these rare glowing patches can cover areas larger than 15,000 square kilometers—visible even from space. ✨
#ocean⚡#mysteries⚡#bioluminescence⚡#bacteria
👉subscribe Interesting Planet