В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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 galaxy HD1, discovered in 2022, may be the most distant known object in the universe—its light has traveled more than 13.5 billion years to reach us. Observing HD1 gives astronomers a rare window into the universe just 300 million years after the Big Bang, offering clues to how the earliest galaxies and stars began to form in the cosmic dawn. ✨
#galaxies⚡#distance⚡#earlyuniverse⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The James Webb Space Telescope has spotted the earliest known supermassive black holes in galaxies that formed less than a billion years after the Big Bang, such as in the galaxy GN-z11. These giant black holes are much more massive than scientists expected for such young galaxies, forcing astronomers to rethink how quickly these cosmic monsters can grow in the very early universe. ✨
#blackholes⚡#webb⚡#earlyuniverse⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The James Webb Space Telescope has uncovered giant, star-forming galaxies such as CEERS-93316 that existed less than 250 million years after the Big Bang. These ancient galaxies are much larger and brighter than scientists expected, revealing that massive cosmic structures began assembling much earlier in the universe’s history than previously thought. ✨
#galaxies⚡#earlyuniverse⚡#jwst⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The cosmic microwave background—often called the afterglow of the Big Bang—shows that the universe was filled with a hot, dense plasma about 380,000 years after its birth. When the universe cooled enough for atoms to form, light was finally able to travel freely, leaving behind a faint, uniform glow that we still detect today and which blankets galaxies like the Milky Way and Andromeda in every direction. ✨
#bigbang⚡#earlyuniverse⚡#cosmology⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The star SDSS J102915+172927 in the constellation Leo is one of the most chemically primitive stars ever found, containing almost no elements heavier than hydrogen and helium. Its incredibly simple makeup suggests it formed from material left over from the very first stars in the universe, making it a true relic from the cosmic dawn. ✨
#unusualstars⚡#leoconstellation⚡#earlyuniverse⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The cosmic microwave background holds a hidden fingerprint—tiny temperature fluctuations mapped in exquisite detail by satellites like Planck reveal how the first stars and galaxies, such as those in the ancient cluster Abell 2744, grew from initial small ripples in the early universe. These faint variations, just millionths of a degree, became the seeds around which all the cosmic structures we see today first assembled. ✨
#cosmicmicrowavebackground⚡#earlyuniverse⚡#galaxyclusters⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#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
🪐 Stretching across all of space, the cosmic microwave background is sprinkled with mysterious "hot" and "cold" rings—subtle patterns first mapped by the Planck satellite. One of these ring structures, dubbed the "CMB rings," shows up as smooth, circular features and could be the leftover imprint of massive waves moving through the young universe, giving scientists a unique window into the conditions just hundreds of thousands of years after the Big Bang. ✨
#cosmicmicrowavebackground⚡#earlyuniverse⚡#planck⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels