В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🪐 When the European Space Agency’s Planck satellite mapped the cosmic microwave background—the faint afterglow of the Big Bang—it found the universe’s temperature is nearly uniform everywhere, but with subtle hot and cold spots only millionths of a degree apart. These tiny temperature variations, scattered across the sky, serve as a cosmic “fossil record,” encoding clues to how galaxies, clusters, and the vast cosmic web evolved from the universe’s earliest moments. ✨
#microwaveradiation⚡#bigbang⚡#universe⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The cosmic microwave background, a faint glow that bathes the entire universe, carries subtle imprints called "acoustic peaks"—tiny wiggles in its temperature pattern, mapped by observatories like Planck. These acoustic peaks reveal the sound waves that rippled through the hot, dense plasma of the early universe, showing how matter and energy once "rang" together before the first atoms even formed. ✨
#microwaveradiation⚡#earlyuniverse⚡#planck⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 In 2003, NASA's Wilkinson Microwave Anisotropy Probe (WMAP) created an all-sky map showing subtle temperature differences in the cosmic microwave background, the afterglow of the Big Bang. WMAP’s high-resolution data revealed a puzzling "cold spot" in the direction of the Eridanus constellation, a region cooler than expected that could hint at some of the universe’s deepest cosmic mysteries—such as massive voids or unusual early-universe physics. ✨
#microwaveradiation⚡#WMAP⚡#Eridanus⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The cosmic microwave background—an ancient light left over from the Big Bang—contains a hidden signal: tiny patterns of polarization, or the way its waves are oriented. These "B-modes," discovered in part by the BICEP2 telescope at the South Pole, are faint twists in the light that could provide direct evidence of gravitational waves rippling through the early universe, opening a window into its very first moments. ✨
#microwaveradiation⚡#polarization⚡#gravitywaves⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries