В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
March 21 – Human Rights Day in South Africa
This day commemorates the Sharpeville Massacre (1960), when police opened fire on peaceful protesters opposing the Pass Laws, killing 69 people and injuring 180.
The Pass Laws restricted black South Africans' movement, requiring them to carry passbooks with personal details, residency and work permits, and employer confirmations. These had to be presented on demand to police and officials.
On March 21, 5,000–10,000 demonstrators gathered at a police station, offering arrest for not carrying passbooks. Instead, they faced brutal repression.
Human Rights Day serves as a reminder of the fight for freedom and equality.
#HumanRightsDay#SharpevilleMassacre#Apartheid#SouthAfrica#History
This year marks 75 years of the Universal Declaration on Human Rights.
For 75 years, the UDHR has defined our key rights and been a rallying cry for Human Rights Defenders all over the world.
In #HumanRightsDay we join over 57 organisations in urging First Minister @HumzaYousaf to put #AllOurRights in law for everyone. Make the Universal Declaration a reality!
We hope @scotgov to listen to civil society concerns & make the Bill as strong as possible.
#HumanRights75#AllOurRights
#AllOurRights
今年係《世界人權宣言》通過75周年。75年來,宣言 界定咗我哋嘅關鍵權利。
今年人權日,我哋連同57個蘇格蘭公民團體去信蘇格蘭首席大臣 Humza Yousaf,促請政府引入人權法案時,投入充分資源,包括但不限於保障殘疾人士、更包容的平等對待、改善弱勢支援等,並加強與公共機構合作,增加機構對人權法案嘅認知同逐步實施相關政策。
我哋敦促蘇格蘭政府聆聽民間社會嘅聲音,讓人權公約能夠喺蘇格蘭得以實踐。
#國際人權日#人權公約#世界人權宣言#生而平等#首席大臣#蘇格蘭政府
Letter to Scot Cabinet on Human Rights
https://www.patreon.com/posts/94309170