В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
UN EXPERTS DEMAND SAFE PASSAGE FOR ‘MADLEEN’
JOIN THEM
Today, UN experts called for safe passage for the Madleen — our civilian ship carrying vital aid and international volunteers to Gaza.
Now we need your voice. Let’s turn international law into action.
📣 Take one minute: go to bit.ly/IsraelOnNotice and send a letter to the Israeli government, UN officials, and diplomatic missions demanding that Israel abide by international law and refrain from attacking, sabotaging or otherwise interfering with the Madleen and her mission.
Together, we can open a people’s sea corridor to Gaza. #SafePassage#BreakTheSiege#FreedomFlotilla
Six of the seven U.S. citizens aboard the Freedom Flotilla’s ‘Handala’ just read a powerful open letter to Donald Trump and the U.S. government. From the founder of Amazon Labor Union’s to a U.S. war veteran, a lawyer, a marine rescue worker, a human rights attorney, and an actor—each one delivered a searing truth: the U.S. is an active participant in Israel’s war crimes against Palestinian children in Gaza. If the U.S. does not support the deliberate starvation of children, they should guarantee safe passage of ‘Handala’.
‘Handala’ plans to deliver food, medicine, and baby formula to Gaza in a few days. They are unarmed, trained in nonviolence, and yet, are under threat by Israel. If anything happens to them, the world will know who is responsible.
Share this. Tag your politicians. Break the silence. Let the world see who’s standing on the right side of history.
#PresidentTrump#Handala#SafePassage#FreedomFlotilla#ForTheChildrenOfGaza#StandWithGaza#AllEyesOnDeck
🚨 ACTION ALERT: The UK MUST protect ‘Madleen’ 🚨
The ‘Madleen’ is a UK-flagged civilian ship sailing to Gaza with life-saving aid as part of the #FreedomFlotilla. The UK has a legal duty to protect its vessel and the civilians aboard from Israeli interference.
🇬🇧 Under international law, the UK must:
• Prevent genocide
• Reject Israel’s illegal blockade of Gaza
• Defend its flagged ship from unlawful attacks
Support us by taking action! Contact the Foreign Office and your MP. Demand protection for the ‘Madleen’ and accountability for any aggression.
Email: [email protected]
X: @FCDOGovUK
IG: @ForeignAndDevelopmentOffice
Tel: 020 7008 5000
#SafePassage#UKResponsibility#BreakTheSiege#BreakIsraelsSiege#EndComplicity#Madleen#GazaGenocide#FreedomFlotilla
🚀 Malaysian Prime Minister Confirms Safe Passage of Oil Tankers Through Hormuz Strait
On April 10, Malaysian Prime Minister Anwar confirmed that six out of seven oil tankers heading to Malaysia have successfully navigated the Hormuz Strait. According to BlockBeats, the remaining vessel is currently undergoing repairs due to mechanical issues and remains docked at the port.
#MalaysianPrimeMinister#OilTankers#HormuzStrait#SafePassage#Anwar#MechanicalIssues#BlockBeats#Malaysia