В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🌎 On Neptune’s largest moon Triton, geysers of nitrogen ice erupt from beneath the surface, shooting plumes up to 8 kilometers high into the tenuous atmosphere. These cryovolcanic eruptions are driven by sunlight warming a thin layer of transparent ice, a unique phenomenon that shapes Triton's mysterious, dark-streaked terrain. ✨
#Triton⚡#cryovolcanism⚡#Neptune
👉subscribe Universe Mysteries
🪐 On Triton, Neptune's largest moon, icy volcanoes known as cryovolcanoes have been observed erupting plumes of nitrogen gas many kilometers high. This frigid world’s surface is scattered with dark streaks—evidence of these geysers venting from below, hinting at surprising geologic activity beneath its frozen crust. ✨
#Triton⚡#cryovolcanoes⚡#Neptune
👉subscribe Universe Mysteries
🪐 On Neptune’s moon Triton, geysers erupt through its icy crust, blasting nitrogen gas more than 8 kilometers above the surface. These plumes create dark streaks and ever-changing patterns on Triton's frozen landscape, transforming the distant moon into one of the most dynamic worlds in the outer solar system. ✨
#Triton⚡#geysers⚡#Neptune
👉subscribe Universe Mysteries
🪐 Within our solar system, scientists have discovered that the subsurface ocean of Neptune’s moon, Triton, could provide the right conditions for life despite its bitterly cold surface. Tidal forces, or gravitational stretching from Neptune, may keep this hidden ocean liquid beneath Triton’s icy shell, making it a fascinating target in the ongoing search for places where life could exist beyond Earth. ✨
#Triton⚡#ocean⚡#astrobiology⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 Neptune’s largest moon, Triton, is thought to conceal a hidden ocean beneath its frozen exterior, thanks to heat generated by radioactive decay in its rocky core. Despite surface temperatures near minus 235°C, this internal heat may keep water liquid deep inside, making Triton one of the most intriguing ocean worlds in the outer solar system. ✨
#Triton⚡#oceanwonder⚡#Neptune⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels