В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
Now with Israel's attack on Iran, the airports are shut down, and our three remaining 'Madleen' team members, Pascal Maurieras, Yanis Mhamdi, and Marco van Rennes may face an extra month, illegally detained in Israeli prison.
All three were meant to be released and flying back to their families today, June 13. The French and Dutch governments must find alternative routes and get their citizens home, whether through Jordan or otherwise - NOW.
Contact details in our slides and email template in our stories.
#BreakIsraelsSiege#EndTheBlockade#Madleen#WeWillSail#AllEyesOnDeck#StandWithMadleen#StandWithPalestine
Şuayb, our beautiful friend and man capable of any job, was abducted in international waters, while trying to bring food and medicine to Palestinians in Gaza. His wife, Sumerya, shares their story about joining the Freedom Flotilla Coalition last year in Istanbul for the 'Break the Siege' action, followed by 'Handala', the 'Conscience', and now 'Madleen'. She carries his voice forward—because this was never just about any of us. It’s about Palestinians who have endured Israel's brutal siege, aparthied, occupation, unlawful imprisonment, bombs, and global silence for far too long. Gaza is still waiting. And so we must keep sailing.
#WeWillSail#BreakIsraelsSiege#EndTheBlockade#StandWithMadleen#StandWithGaza#AllEyesOnDeck#FreePalestine#Şuayb