В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🇷🇺🇧🇳🇰🇭🇮🇩🇱🇦🇲🇾🇲🇲🇵🇭🇸🇬🇹🇭🇻🇳 Deputy Minister of Defence of the Russian Federation AleksandrFomin is taking part in the 10th ASEAN Defence Ministers’ Meeting Plus (ADMM-Plus).
📍 Jakarta, November 16
#RussiaADMMPlus
🗓 On November 16, Deputy Minister of Defence of the Russian Federation Aleksandr Fomin 🇷🇺 headed Russian delegation at the 10th ASEAN Defence Ministers’ Meeting Plus (ADMM-Plus) in Jakarta, Indonesia 🇮🇩.
💬All these years the Russian Ministry of Defence has been actively engaged in the ADMM-Plus process and continues to contribute to strengthening our common security. Russia supports all positive initiatives put forward by other partners in all spheres of military cooperation.
🔹️On the sidelines of the meeting, Colonel General Aleksandr Fomin held bilateral meetings with the heads of the defence ministries of Laos 🇱🇦, Brunei 🇧🇳, Indonesia 🇮🇩, and the Secretary-General of #ASEAN.
#RussiaADMMPlus
🗓 On November 21, Deputy Minister of Defence of the Russian Federation, Colonel General Aleksandr Fomin🇷🇺 participated in the 11th ASEAN Defence Ministers’ Meeting Plus (#ADMM-Plus) in Vientiane, the Lao PDR 🇱🇦.
🔹️In his address to ADMM Plus, the Russian Deputy Defence Minister outlined Russia's position on the most pressing security issues facing the world and the Asia-Pacific region.
🔹️At the event, ASEAN Member States confirmed their readiness to work with the Russian Ministry of Defence in key areas of military cooperation of mutual interest.
🔹️On the sidelines of the meeting, Colonel General Aleksandr Fomin held bilateral meetings with the heads of the defence ministries of Vietnam 🇻🇳, Laos 🇱🇦, Malaysia 🇲🇾 and East Timor 🇹🇱 to discuss in detail bilateral military cooperation as well as prospects for cooperation in regional multilateral formats, in particular ADMM Plus.
#RussiaADMMPlus