В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🏡 Heard of the '80-80-80 in 2030' targets?
🏗 The three targets outlined in the Singapore Green Building Masterplan will help pave the way for a low-carbon built environment; creating healthy, liveable, and sustainable spaces for everyone.
➡️ Read more at: https://go.gov.sg/mndcos-js
#BuildSG#SGGreenPlan
The Covid-19 pandemic has hit the construction industry hard, leading to a delay in many projects, including HDB BTO flats.
Hear what Minister Desmond Lee has to say about support for BTO flat buyers.
#publichousing#HDB#BuildSG#SGTogether
https://youtu.be/i3hxLHY9eb0
Here's a look at the new and enhanced initiatives that we announced at the MND's Committee of Supply 2025 to work towards creating an endearing home and distinctive city. Scroll to see how these initiatives could benefit you!
For more info: www.mnd.gov.sg/cos2025
#COS2025#Budget2025#MNDCOS2025#sghousing#CityinNature#buildsg
#ICYMI Whether you are a homebuyer, nature-lover, part of the construction industry, or simply a resident in Singapore, here’s how the new and enhanced initiatives from MND’s Committee of Supply 2024 will benefit you!
More details on www.mnd.gov.sg/cos2024
#COS2024#Budget2024#MNDCOS2024#hdb#bto#sghousing#sgliving#CityinNature#BuildSG