В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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 truth is that the European Union entered the #RussiaUkraineWar recklessly, based on flawed calculations and with a misguided strategy, and I attribute this to the actions of President @vonderleyen.
https://t.me/PM_ViktorOrban
Mood in Russia turns bleak as war in Ukraine drags on and economy suffers
[Read FullArticle]
@WorldNews#RussiaUkraineWar#RussianEconomy#GlobalNewsUpdate
'Serious disruption' — Russian oil pumping station in Nizhny Novgorod Oblast hit by Ukrainian drones, SBU source says
[Read FullArticle]
@WorldNews#RussiaUkraineWar#UkrainianDrones#OilInfrastructure
Russia suffers ‘record’ soldier casualties as Ukraine ups drone production | Russia-Ukraine war News
[Read FullArticle]
@WorldNews#RussiaUkraineWar#UkraineDroneStrike#WarNewsUpdate
❗️🇷🇺🇺🇦We will win by all means, but it's better to win sooner, so that fewer people from this side and that side die!
"Our president did everything he could to avoid war, but he was not heard and did not want to be heard," says a Russian soldier who was mobilized last September, one should always try to negotiate. And President Putin offered to sit down at the negotiating table, but instead the Ukrainians were seriously preparing for war! But we will definitely win, because we cannot retreat, we have to solve it here and now, otherwise they will come to us! Of course, we would like it to be quicker, so that fewer people would die on this side and on that side. Precisely peaceful people, not Nazis. Participating in this special operation is our man's duty, says the young warrior!
#RussiaUkraineWar
#frontNews
#RussiaVictory
https://t.me/heroesofZ/312
📱InfoDefenseENGLISH
📱InfoDefense
The Commonwealth of Independent States (CIS) was established on 8 December 1991 to succeed the Soviet Union, but Russia’s 2014 Crimea annexation and 2022 invasion have deeply shaken its unity and future. 🌐
[Read more]
@googlefactss
#CIS#Geopolitics#RussiaUkraineWar#History#InternationalRelations