В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
Why We’re Here. Why Now. 🚫👑
Look, we all feel it. Whether you’re on the left, the right, or somewhere in the middle—it doesn’t matter. This isn't about a political party. This is about the fact that we were never meant to be subjects. We were meant to be Citizens.
The "No King" movement isn't just a hashtag; it’s a wake-up call. We’re watching a system where the elites act like royalty while the rest of us struggle to keep our heads above water. If we don't stand up now, if we stay silent, the future won't belong to us—it’ll belong to those who think they own us.
We get it. Not everyone can march in the streets. Not everyone can be on the frontlines. Some of you are busy working two jobs, raising kids, or just trying to survive. But in your heart, you know the current path is broken. You know things must change.
How can you help? It’s simple. Truth is our greatest weapon. Smallest act of defiance? Share. Share the posts here. Spread the word. Don't let the "official" narrative be the only one people hear.
We aren't asking for your vote. We’re asking for your voice.
No Masters. No Monarchs. No Kings. ⛓
#NoKings#PowerToThePeople#TheUnruled#AmericaAwakened
✈️📣t.me/No_king_No_King
Why We’re Here. Why Now. 🚫👑
Look, we all feel it. Whether you’re on the left, the right, or somewhere in the middle—it doesn’t matter. This isn't about a political party. This is about the fact that we were never meant to be subjects. We were meant to be Citizens.
The "No King" movement isn't just a hashtag; it’s a wake-up call. We’re watching a system where the elites act like royalty while the rest of us struggle to keep our heads above water. If we don't stand up now, if we stay silent, the future won't belong to us—it’ll belong to those who think they own us.
We get it. Not everyone can march in the streets. Not everyone can be on the frontlines. Some of you are busy working two jobs, raising kids, or just trying to survive. But in your heart, you know the current path is broken. You know things must change.
How can you help? It’s simple. Truth is our greatest weapon. Smallest act of defiance? Share. Share the posts here. Spread the word. Don't let the "official" narrative be the only one people hear.
We aren't asking for your vote. We’re asking for your voice.
No Masters. No Monarchs. No Kings. ⛓
#NoKings#PowerToThePeople#TheUnruled#AmericaAwakened
✈️📣t.me/No_king_No_King
A guy whose rap sheet for pedophilia is growing day by day shouldn't be anywhere near a position of power in this country.
#NoKings
#TheUnruled
#AmericaAwakened
#Epsteinfile
✈️📣t.me/No_king_No_King