В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🔒Final of Zealy.io: New Chapter Begins🤝
🌐We're thrilled to inform you that the official launch of the SLEX exchange has successfully taken place, and it's time to say goodbye to the Zealy.io testnet🌟
❤️We're grateful to all the participants who joined the testnet and diligently completed various activities, but we've identified a significant number of multi-accounts🤖
🗓We take fairness and integrity seriously, so we'll announce the results of the testnet's user activities after a thorough review.
🤝Thank you for being a part of the SLEX community and your unwavering support. Stay tuned for more SLEX updates and developments!
#SLEXlaunch#testnetzealy#SLEXcontest#SLEX
Email | Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
🔒SLEX Rewards Form Now Closed - Thank You for Participating! 🌟
Dear SLEX Community,
🎉We're thrilled to announce that our SLEX rewards form is closed! Thank you to everyone who participated and shared in this exciting opportunity. You will receive your SLEX coins just after the official listing🚀
🎁Stay tuned for more updates and prepare to trade SLEX coins on SLEX Exchange!
#SLEX#SLEXExchange#SLEXRewards#SLEXContest#SLEXCoin
Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
☄️Grab up to $100 for Registration on SLEX
🔥The SLEX is excited to announce our exciting deal, where the first 500,000 users will have the opportunity to earn up to $100 in bonuses just by making simple onboarding actions on our Centralized Exchange!
🌈Dive into this link and find out this simple Steps & Get your 100$ Reward:
👉slex.io/onboarding-campaign👈
Hurry up, this is a Limited-Time Deal 😉 Join SLEX CEX and Invite your Friends to join us & get up to a $100 reward!
🤝Join SLEX Official Twitter Channel for being in touch with upcoming deals & offers for SLEX community members!
#SLEXOnboarding#CryptoBonus#SLEXExchange#SLEXContest#WelcomeBonus
Email | Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter