В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
EXCLUSIVE Adviser to jailed HK tycoon #JimmyLai says #AppleDaily to shut within days
http://reut.rs/3xH41hf
路透引述黎智英助手表示《蘋果日報》或於數天內被迫關閉 壹傳媒續停牌
https://www.mpfinance.com/fin/instantf2.php?node=1624235954066&issue=20210621
Media mogul Jimmy Lai, founder of Next Digital and Apple Daily, faces charges of "collusion with foreign forces" and other offenses. Prosecutors claim Lai used his media platform to incite hatred against the Hong Kong government and China. The case involves 161 articles, including Lai's columns and Apple Daily reports, urging protests and international sanctions against China. Prosecutors allege Lai contacted foreign politicians, including former US Vice President Pence and Secretary of State Pompeo, seeking sanctions. Lai pleads not guilty.
Charges against Jimmy Lai for "collusion with foreign forces" are seen as baseless, stifling dissent and freedom of speech. Targeting prominent figures like Lai undermines democracy and human rights. We must condemn attempts to silence dissent. #JimmyLai#FreedomOfExpression#AppleDaily#HongKong
Jan 3: on day 5 of #JimmyLai's trial, prosecutors claiming he directed #AppleDaily's English edition to promote "yellow" viewpoints and seek foreign sanctions. They mention Lai's Twitter account, where he followed figures like Tsai Ing-wen and Mike Pence. The judge questioned the relevance, but prosecutors argue it shows Lai's connections and state of mind. Critics see these charges as an attack on free expression.
Jimmy Lai's trial highlights the concerning reality that having a Twitter account can now be used against individuals in prosecutions. The case underscores the potential risks individuals face for expressing their viewpoints and connecting with others on social media platforms. #FreedomOfExpression#freehk#freepoliticalprisoners
Dec 18: Founder of Apple Daily, Jimmy Lai, along with three Apple companies, is being tried in the High Court for charges of conspiring with foreign forces and conspiracy to publish seditious publications. The case raises concerns about how the national security law threatens human rights in Hong Kong. Notably, Lai has already spent over 3 years in jail before the trial, highlighting the government's practice of punishing political prisoners even before their day in court. The trial continues tomorrow. #JimmyLai#AppleDaily#PressFreedom#HumanRights#NationalSecurityLaw#HighCourt
Dec 19: Founder of Apple Daily, Jimmy Lai, and three Apple companies continue their trial on charges of conspiring with foreign forces and publishing seditious publications. Yesterday, the defense argued that the prosecution's addition of sedition charges exceeded the time limit for prosecution. Today, they added that the prosecution should have timely initiated charges due to the six-month limit for sedition offenses. The prosecution contends that the conspiracy was ongoing, citing over 160 seditious publications released by Lai within two years. The judge will rule on the legal dispute this Friday.
Legal dispute arises as the six-month time limit for sedition offenses becomes a focal point in the trial of Jimmy Lai and the Apple Daily companies. Defense argues charges exceed the limit, questioning court jurisdiction. Prosecution contends ongoing conspiracy justifies charges. Ruling expected Friday. #JimmyLai#AppleDaily#Trial#LegalDispute#SeditionCharges
Jimmy Lai's son, Sebastien Lai, has once again appealed to the U.S. government for help in securing his father's release. In an article published by The Boston Globe, Sebastien expressed hope in President Trump's leadership, referencing his past comments about freeing Jimmy Lai.
With the UK government accused of kowtowing to China, Sebastien emphasized that Trump remains the only hope for his father’s freedom, claiming that Trump had previously referred to Jimmy Lai as a friend before his second term began.
#JimmyLai#AppleDaily#Trump#NationalSecurityLaw
壹傳媒創辦人黎智英的兒子黎崇恩再次呼籲美國政府協助釋放黎智英。《波士頓環球報》刊登黎崇恩的文章,他提到對特朗普曾表示釋放黎智英的言論感到振奮,並寄望其領導能力。
隨著英國政府被指向中國屈服,黎崇恩強調,特朗普是黎智英獲釋的唯一希望,並稱特朗普在第二任期開始前曾表示黎智英是他的朋友。
#黎智英#蘋果日報#特朗普#國安法
年屆77歲的香港傳媒大亨黎智英,其牢獄歲月於周五(7日)踏入第1500日。他是許多被中國共產黨在香港監禁的政治犯之一,法治已完全消失。
英國人權組織《香港監察》創辦人羅傑斯呼籲全球領導人營救黎智英,並敦促教宗方濟各關注其信仰權利,釋放這位虔誠的天主教徒。
#黎智英#JimmyLai#蘋果日報#新聞自由#人權
At 77, Hong Kong media mogul Jimmy Lai has spent 1,500 days in prison as of Friday (7th). He is one of many political prisoners jailed by the CCP in Hong Kong, where the rule of law has vanished.
Benedict Rogers of Hong Kong Watch calls on global leaders to rescue Lai and urges Pope Francis to advocate for his release, considering his rights as a devout Catholic.
#JimmyLai#AppleDaily#FreePress#HumanRights
彭定康在國際知名評論平台發文
讚揚黎智英堅定不移的民主精神
香港《壹傳媒》創辦人黎智英已被還押逾3年,其涉及的《港區國安法》案件被一拖再拖,末代港督彭定康周三(30日)於國際知名評論平台「Project Syndicate」網站發文,形容黎智英堅定不移的民主精神,彰顯人性的不屈不撓,惟憂慮在中共極權下,黎智英恐獄中度過餘生。
彭定康以《一線希望(A Smidgen of Hope)》為題,提及現時全球各地動盪災禍不斷,包括俄烏戰火持續、美國夏威夷山火及中國華北水災等,繼而引伸一部近月發布的黎智英個人紀錄片《為自由而戰》(The Hong Konger: Jimmy Lai's Extraordinary Struggle for Freedom),指當中透過黎智英的遭遇,切實反映在中國國家主席習近平領導下,香港的新聞自由和法治遭受前所未有的打壓。
文中指,黎智英當初由大陸的共產主義逃離到香港,再白手起家成為媒體大亨,多年來關注中國的人權侵害,包括在1989年「天安門廣場大屠殺」(1989 Tiananmen Square massacre)後持續直斥(vocal criticism)前中國國務院總理李鵬等領導人。即使惹來北京反感,但他仍無畏地提倡言論自由、民主和法治,投入民主運動,最終因而多項「莫須有」罪名(trumped-up charges)被判囚6年以上。
彭定康在文末指,黎智英在紀錄片的一句中國古老諺語發人深省:「鳥之將死,其鳴也哀。」(a bird, he said, would choose death over a life shrouded in silence)
#黎智英#彭定康#ChrisPatten#JimmyLai#蘋果日報#AppleDaily#新聞自由無價#守護真相#撐蘋果#壹傳媒#滅聲
報導:自由亞洲粵語 @rfacantonese