В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🪐 Far away in the constellation Pegasus, the exoplanet HD 209458b—nicknamed "Osiris"—boils under such intense heat from its star that its atmosphere is literally being blown away into space. Powerful ultraviolet radiation strips gases from the planet, creating a long, glowing tail of material that stretches behind it like a giant comet, showing how extreme conditions can rewrite the rules for how planets survive. ✨
#exoplanets⚡#extremes⚡#atmospheres⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The exoplanet WASP-19b, located about 815 light-years away in the constellation Vela, orbits its star so closely that a year lasts less than 19 hours and daytime temperatures exceed 2,000°C—hot enough to break molecules apart. Studies with the Hubble Space Telescope have revealed its atmosphere contains titanium oxide, a compound rarely found in planetary atmospheres, which acts like sunscreen by absorbing stellar radiation and heating the upper atmosphere to even greater extremes. ✨
#exoplanets⚡#extremes⚡#atmospheres⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The exoplanet GJ 436b, orbiting a star 33 light-years away in Leo, is a world of extremes—its atmosphere is so hot, over 800°C, that its water vapor is stripped away by intense radiation, creating a huge, comet-like tail of gas trailing behind it. This ghostly plume stretches for millions of kilometers, revealing just how dramatically a star’s energy can reshape planets beyond our solar system. ✨
#exoplanets⚡#extremes⚡#atmospheres⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The giant planet HD 189733b, located about 64 light-years away in the constellation Vulpecula, is famous for having blue clouds made of molten glass that whip through its atmosphere at wind speeds over 7,000 kilometers per hour. Unlike Earth's gentle blue sky, the blue color of HD 189733b comes from silicate particles that scatter blue light, creating a world where glass rain falls sideways in scorching, stormy gales. ✨
#exoplanets⚡#giantplanets⚡#atmospheres⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The James Webb Space Telescope has detected carbon dioxide on the exoplanet HD 189733b, a giant world 64 light-years away in the constellation Vulpecula. This is the first time carbon dioxide—a common gas on Earth—has been firmly identified in the atmosphere of an exoplanet, using Webb’s powerful infrared instruments to reveal details about the planet’s chemistry and hint at how its formation differs from giant planets in our own solar system. ✨
#webb⚡#exoplanet⚡#atmospheres⚡#discoveries⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels