В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🇿🇦The Office of the Honorary Consul of the Republic of South Africa in Yekaterinburg extends its warmest congratulations to President Cyril Ramaphosa on his birthday! 🎉
We wish the South African leader good health, prosperity, and continued success in strengthening Russian–South African relations! 🇷🇺🤝🇿🇦
#SouthAfrica#Birthday#Diplomacy#Cooperation#Russia#CyrilRamaphosa
🇷🇺🤝🇿🇦 Ambassador-designate of Russia to South Africa Roman Ambarov took part in the event to commemorate the Day of Reconciliation in Vredendal, Western Cape.
The celebration was arranged by the Department of Sports, Arts and Culture of South Africa with Minister Gayton McKenzie acting as the program moderator.
🎙 President Cyril Ramaphosa delivered the keynote address pointing out that this Day of Reconciliation’s theme is “Healing historical wounds and forging new futures.” It is an occasion where South Africans remember and celebrate their journey as a country towards nation-building, healing, social justice and forgiveness, he emphasized.
We are all bound together by the spirit of Ubuntu. The word “Ubuntu” has its roots in the IsiZulu phrase “umuntu ngumuntu ngabantu” – “A person is a person through other people,” “I am because we are” - Cyril Ramaphosa noted.
“This day is of great historical significance. It is a reminder that the country went through centuries of divisions and conflicts. But instead of hatred and revenge, South Africans chose reconciliation and nation-building, as Nelson Mandela, the first democratically elected President of South Africa once said.
On this day, #Russia sincerely wishes the friendly South African people peace, harmony and unity!” Ambassador-designate Roman Ambarov said on the sidelines of the event.
#ReconciliationDay2024#UniteAgainstAllIntolerances#Ambarov#EmbassyofRussia#SouthAfrica#CyrilRamaphosa#GaytonMcKenzie