В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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 comets
This is an image of the comet C/2006 P1, commonly known as McNaught.
Scientists observed its tail modifying attributes of the solar wind, which is impossible by the standard model, which claims that comets are 'dirty snowballs'.
In reality, comets are charged rocks which spend most of their time in the outer regions of the solar system, where they accumulate a negative charge until they start their journey into the center of the solar system.
Their tails are visible electric discharge phenomena.
To recognize the electrical nature of comets, means recognizing the electrical nature of the universe and is key in understanding spirituality.
#astronomy#comets
@EuropeanTribalism
🪐 A comet named 12P/Pons-Brooks, known as a "cryovolcanic comet" for its icy volcanic eruptions, will make a close approach to Earth in 2024. When this comet nears the Sun, its surface cracks and blasts out dust and frozen gases into space, creating dramatic outbursts and a bright, glowing coma—a reminder of how large icy bodies can suddenly liven up and send material toward our planet’s neighborhood. ✨
#comets⚡#hazards⚡#spaceweather⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 One of the largest comets ever observed, C/2014 UN271 (Bernardinelli-Bernstein), is traveling through our solar system and is estimated to be about 150 kilometers wide—over 1,000 times bigger than a typical comet. Although it won't come close enough to threaten Earth, its sheer size shows that massive objects from the far reaches of the solar system, like the distant Oort Cloud, could pose a significant risk if their paths ever brought them near our planet. ✨
#comets⚡#oortcloud⚡#threats⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels