В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
2019 Chinese University of Hong Kong (CUHK) Siege Timeline:
- Nov 11-12: Police initiate action by entering CUHK campus, sparking clashes.
- Nov 12: Police deploy tear gas, rubber bullets, and bean bag rounds; clashes last for hours, with dozens injured.
- Nov 12 (Evening): University president Rocky Tuan mediates; police agree to withdraw, but tensions persist.
- Nov 13: Aftermath continues as campus calms, becoming a symbol of the protests.
- Police Brutality Details: According to Amnesty International and Human Rights Watch reports, police used excessive force, including close-range rubber bullet shots causing eye injuries, beatings of detainees, and indiscriminate tear gas affecting students and non-protesters.
#HongKongProtests#2019HongKong
Timeline of Chow Tsz-lok's Death:
- Nov 3, 2019 (Evening): Protests in Tseung Kwan O escalate; police deploy tear gas.
- Nov 4, 2019 (Around 1 AM): Chow falls from 3rd floor of Sheung Tak Estate car park, suffers severe injuries; reports claim police were present at the parking lot at the time.
- Car park fence is 1.3m tall, making accidental fall unlikely for an adult, raising suspicions.
- Chow had severe head injuries but no other broken bones; critics claim this proves he was unconscious before the fall.
- Nov 4, 2019: Ambulance delayed due to roadblocks, with reports claiming police cars blocked the way; Chow admitted to hospital in coma.
- Nov 8, 2019 (Morning): Chow pronounced dead at age 22 from cardiac arrest.
- Jan 2021: Coroner's inquest did not rule accidental death, but exact cause of fall undetermined; critics allege the judge misled the jury multiple times that it was an accident.
- A tragic symbol of Hong Kong's 2019 protests—remembering the call for justice.
#ChowTszLok#HongKongProtests
Legal expert Johannes Chan Man-mun explains the permanent nature of the "interim" injunction in Hong Kong's protest case, with no avenue for appeal to the Court of Final Appeal. Chan criticizes the court's decision to deny intervention, highlighting the challenges in challenging the ban. He emphasizes the undermining of human rights and suggests legislative action instead of relying on court injunctions. Human rights concerns persist in Hong Kong. #HongKongProtests#LegalRuling#HumanRights