В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
#HongKong police have arrested and detained the father of wanted activist #AnnaKwok, accusing him of handling her financial assets. This marks the first time authorities have used the #NationalSecurityLaw to prosecute the relatives of an overseas activist.
Critics warn that #HongKongpolice are now acting like China’s security forces, using laws to hold families of opposition figures hostage. Many fear Kwok’s family will remain under strict surveillance, limiting their freedom even after release.
#PoliticalRepression#HumanRights
#香港 警方逮捕並拘留了流亡民主運動人士 #郭鳳儀 的父親,指控他處理女兒的財務資產。這是當局首次使用 #國安法 來起訴海外民主運動人士的家屬。
批評者警告,#香港警方 正效仿中國的安全部門 ,利用法律挾持反對派人士的家屬。許多人擔心郭氏家族即使獲釋,也將受到嚴密監視 ,自由將受到極大限制。
#政治打壓#人權
#CCP bans Tiananmen vigil, intensifies crackdown in #HongKong
On the 36th anniversary of the Tiananmen Square Massacre, #HongKongPolice deployed heavy forces, detaining at least 12 people, including activists carrying symbolic items.
🔹 2 arrested – A mainland woman* and a local man were detained for failure to produce ID & obstructing police officers.
🔹 10 others taken away – 5 men and 5 women, aged 15 to 69, were detained for "breach of peace", with 3 still in custody.
🔹 CCP’s Erasure of History – The once-massive Tiananmen vigil in Hong Kong is now banned, part of Beijing’s effort to erase the massacre from public memory.
#June4#TiananmenMassacre#PoliticalRepression#HumanRights
#中共 禁 #六四燭光晚會,#香港 鎮壓升級
在 #六四天安門事件 36周年當天,香港警方 重兵駐守 ,拘捕至少12人,包括持有象徵物的市民及社運人士。
🔹 兩人被捕 – 內地女子及本地男子分別因未能出示身份證及阻撓警務人員被捕。
🔹 十人被帶走 – 5男5女 ,年齡介乎15至69歲 ,因「破壞社會安寧」 被扣查,其中3人仍被拘留。
🔹 中共抹去歷史 – 香港六四燭光晚會已被禁止 ,北京正試圖從公眾記憶中抹去大屠殺。
#天安門事件#政治打壓#人權