В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
📖Title : The Return of the King
✍️Author : J.R.R. Tolkien
⭐️Rating : 4.58/5 (Goodreads)
📆Published : Oct 20, 1955
————————————————
Summary:In The Return of the King, the final volume of J.R.R. Tolkien’s The Lord of the Rings, the forces of Gondor and Rohan prepare for the ultimate battle against Sauron. Aragorn embraces his destiny as the true king, rallying allies and marching to the Black Gate as a diversion. Meanwhile, Frodo and Sam struggle through Mordor to destroy the One Ring in Mount Doom. Gollum’s obsession leads to his and the Ring’s destruction, ending Sauron’s reign. Peace returns to Middle-earth, Aragorn is crowned, and the hobbits return to a changed Shire. Frodo later departs with the Elves to the Undying Lands.
————————————————
#fantasy#fiction#classics#adventure#novels#LOTR@Bookslibraryofficial@free_novellas@thesciencelabs
📖Title : The Two Towers
✍️Author : J.R.R. Tolkien
⭐️Rating : 4.50/5 (Goodreads)
📆Published : Nov 11, 1954
————————————————
Summary:In The Two Towers, the Fellowship is broken. Frodo and Sam continue their perilous journey to Mordor to destroy the One Ring, joined reluctantly by the treacherous yet pitiful Gollum, who becomes both guide and threat. Meanwhile, Aragorn, Legolas, and Gimli pursue the Uruk-hai who have captured Merry and Pippin. Their paths lead to the war-torn kingdom of Rohan, where they aid King Théoden against the forces of Saruman. As darkness spreads and war looms, alliances are tested and hope flickers. The story deepens the moral complexity of the quest, showing how power corrupts and loyalty defines true heroism.
————————————————
#fantasy#fiction#classics#adventure#novels#LOTR@Bookslibraryofficial@free_novellas@thesciencelabs