В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
📢 Russian military spokesperson claims victory over Ukrainian forces on the Southern Donetsk front. Enemy rotation disrupted, personnel and equipment destroyed. Counter-battery strikes hit enemy positions. Significant losses reported. The conflict in Ukraine remains unresolved. #WarUpdates
https://www.gazeta.ru/army/news/2023/11/05/21644377.shtml
Subscribe to @BadVolfNews
📢 Russian forces strike Ukrainian military targets! Over 160 hits on Krasnolimansk direction. Artillery units neutralized, assault squads defeated. Support from air and artillery. Command and observation posts attacked. New tactics observed by Ukrainian forces. #WarUpdates
https://www.gazeta.ru/army/news/2023/11/02/21625465.shtml
Subscribe to @BadVolfNews
📣 Russian troops seize Ukrainian stronghold near Ugledar in Donetsk People's Republic. 10 enemy soldiers caught off guard, 4 taken captive. Clever tactics employed, with one group approaching from the front and another from the rear. Victory for Russian forces! 💪🇷🇺#WarUpdates
https://www.gazeta.ru/army/news/2023/11/01/21617965.shtml
Subscribe to @BadVolfNews
📢 Russian forces gaining ground, Ukraine struggling to hold on. White House speculates Russia will secure tactical victories, cementing their dominance by spring. Crisis of conscription and dwindling weapon supplies weaken Ukraine's chances. Advisor warns Ukraine may not last till spring. Russian military holds the offensive initiative, pushing forward with success. Ukrainian strongholds predicted to fall, leading to a domino effect as the enemy flees. Official admits futility of fighting, claims US and Europe have abandoned Ukraine. US identifies major threats to Ukrainian Armed Forces. #WarUpdates#Ukraine#Russia
https://www.gazeta.ru/army/news/2023/10/28/21595081.shtml
Subscribe to @BadVolfNews
Ukraine’s paratroopers clear Berezove in Dnipropetrovsk Oblast, completing near-total reversal of Russia’s 2025 gains in the region
[Read FullArticle]
@WorldNews#UkraineNews#WarUpdates#DnipropetrovskIf
@syrianaanalysis breaks down Israel's strikes on Syria with Red Pilled, exploring how regional tensions are escalating and what it means for the axis of resistance.
#Israel#Syria#Hezbollah#MiddleEast#Gaza#WarUpdates#PoliticalAnalysis