В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
#LetHerBloom#HerLegacy
🌸 Today, we are coming back with our rubric “Her Legacy”, where we dive into lives of women who changed not only theirs, but millions of other women’s lives.
Bloom will tell you who Malala is, her global impact, her achievements, and why she inspires us.
🪄She is the one who taught us that one voice can change revolutions.
Remember:
✨One spark can cause fire that millions of people cannot stop. Be that spark!
💜 Let’s change the world together! Let’s get the strength and change OUR lives.
And after all,
Let Her Bloom!
🚀Telegram | 📷Instagram
#LetHerBloom#BloomTogether#MentalHealthAwareness#AbusePrevention#HerLegacy
🌸Introducing Bloom’s New Rubric Series🌸
We’re launching a fresh series of posts to raise awareness, educate, and create conversations that matter. Here’s what you’ll see on our page:
✨ Abuse 101 – A breakdown of the different types of abuse.
🚩⏺ Red & Green Flags – What’s healthy vs. what’s harmful in relationships.
🧠 Mental Health Impact – The emotional cost of abuse.
🤝 If You Think Someone’s Being Abused – What to do and how to help.
💐 Her Legacy – Stories of powerful women who changed the world.
🌿 Healthy Boundaries – Why they matter and how to set them.
🎬 Feminism in Media – Representation, reality, and rewriting the narrative.
Stay tuned, stay aware, and let’s keep growing together 🌱💜
🚀Telegram📷Instagram