В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
⚠️ We’ve been silent since September 9 on X (twitter) after our account was hacked, but we’ve just recovered it. This came as Venezuela faces new imperialist threats, while VA continues countering mainstream media lies.
👉 Stay tuned for lots of new content: x.com/venanalysis
#Venezuelanalysis
⚠️ Our X (Twitter) account @venanalysis has been hacked, just as US military threats against Venezuela intensify and mainstream media joins the chorus.
We’re working to recover it.
👉 Stay tuned here for updates.
#Venezuelanalysis
Venezuelanalysis is an independent outlet, free from corporate and political backers. Our mission to report on Venezuelan grassroots struggles is unwavering, but we need your support!
📍Make a one-time donation or subscribe to help us reach our goal here: https://venezuelanalysis.com/donate/
#Venezuelanalysis#IndependentJournalism#IndependentMedia#Fundraising
Oppose Trump’s War, Support Venezuelanalysis!
For over 20 years, we’ve stood with the Venezuelan people in their struggle for sovereignty. We’ve exposed US-backed aggression, documented grassroots resistance, and challenged dishonest media narratives.
Every contribution keeps this work alive. Click here to donate 👉https://venezuelanalysis.com/donate/
#Venezuelanalysis#Fundraising2025#IndependentMedia#Venezuela#SupportIndependentMedia
Fundraising 2025! 💪
We launch our yearly fundraising at a moment that feels more critical than ever. With Trump openly threatening to attack Venezuela and the corporate media beating the war drums, independent media must fight back.
For years, Venezuelanalysis has reported from the ground with accuracy and integrity; from documenting popular power to exposing dishonest narratives around sanctions. Today, our task is clear: counter war propaganda and defend peace and Venezuelan sovereignty.
Our work is 100% supported by readers and followers. That’s what keeps us independent. If you value this project, please consider making a donation or becoming a subscriber. Every contribution strengthens our ability to continue reporting in this historic moment.
Click here to donate 👉https://venezuelanalysis.com/donate/
#Venezuelanalysis#Fundraising2025#IndependentMedia#Venezuela#SupportIndependentMedia
🎥 VIDEO | Venezuela's Workers: Bonuses, Frozen Wages, and a Labor Law Under Threat
Venezuela’s minimum wage remains frozen while worker income is increasingly tied to discretionary bonuses. At the same time, proposed changes to the country’s landmark labor law are raising alarm among labor organizations.
Are workers’ rights being quietly dismantled?
Watch the video to learn more: https://youtu.be/rJJLUiLj2NQ
#Venezuela#WorkersRights#LaborLaw#WorkingClass#Venezuelanalysis