В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🌟Join GoPlus SAFU Universe Airdrop Fiesta with your TokenPocket!
Log in through TokenPocket and share in the $2 million super airdrop provided by GoPlus and 10 other Web3 rising stars!
👉https://app.gopluslabs.io/safu?channelCode=tokenpocket
💙 You can use the TokenPocket mobile wallet and the Chrome Extension wallet to be a part of that!
📱https://tokenpocket.pro/en/download/app
💻https://extension.tokenpocket.pro
#Airdrop#GoPlus#TokenPocket#SAFU
🟦 Join SecWareX Planet with your #TokenPocket Wallet!
👉https://secwarex.io/?channelCode=5W7GUXER
Finish TokenPocket Tasks, strengthen your security firewall, and Earn up to 200 energy block rewards!
SecWareX by GoPlus is an innovative, user-centric, full-scope security service platform designed to tackle over 100 security scenarios faced by Web3 users.
#Web3security#GoPlus#SecWareX
【TokenPocket Retweeted】
Retweeted GoPlusEco : It's just about the half time of #ForestAdventure⏰⏰⏰
During this fantastic adventure, more than 5.8K participants had full protection of their wallet and digital assets by #GoPlus, as well as the exclusive offer for #KeyPal🔥🔥🔥
Make sure you finish all the tasks on Galxe and claim the co-branded OAT right before the end time!!! TokenPocket_TP #SaferWeb3#airdrop
Let's do it➡️https://galxe.com/goplussecurity/campaign/GC6G1Uj5zK
【Details】https://twitter.com/GoPlusEco/status/1692036310859698334
【Powered By】Crypto Box