В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
Let's work together to prevent the spread of #Lassafever.
Be a guardian of proper sanitation in your community and promote frequent #Handwashing with soap and running water.
Read our latest #LassaFever situation report:
https://ncdc.gov.ng/diseases/sitreps/?cat=5&name=An%20update%20of%20Lassa%20fever%20outbreak%20in%20Nigeria
Let's work together to prevent the spread of #Lassafever.
Be a guardian of proper sanitation in your community and promote frequent #Handwashing with soap and running water.
Read our latest #LassaFever situation report:
https://ncdc.gov.ng/diseases/sitreps/?cat=5&name=An%20update%20of%20Lassa%20fever%20outbreak%20in%20Nigeria
#Lassafever is preventable.
Be a guardian of proper hand hygiene in your community
Promote frequent #handwashing with soap and running water.
#LassaFeverInfo
#Handwashing with soap under clean, running water is very vital to the prevention of #cholera.
Important #handwashing moments⬇️
✅While caring for the ill
✅After using the toilet
✅Before food preparation
✅Before and after eating
✅After touching high-contact surfaces
#STOPcholera
#Handwashing is a basic and effective tool against infections.
If we do not become sick, we would not need to use #antimicrobials.
Encourage your loved ones to practice frequent #handwashing with soap under running water.
Do your part to prevent #AntimicrobialResistance
#HandHygiene with clean, running water is very vital to the prevention of #cholera.
Important #handwashing moments⬇️
✅While caring for the ill
✅After using the toilet
✅Before food preparation
✅Before and after eating
✅After touching high contact surfaces
#TakeResponsibility
#HandHygiene with soap under clean, running water is very vital to the prevention of #cholera.
Important #handwashing moments⬇️
✅While caring for the ill
✅After using the toilet
✅Before food preparation
✅Before and after eating
✅After touching high contact surfaces
#TakeResponsibility
#HandHygiene with clean, running water is very vital to the prevention of #cholera.
Important #handwashing moments⬇️
✅While caring for the ill
✅After using the toilet
✅Before food preparation
✅Before and after eating
✅After touching high contact surfaces
#TakeResponsibility
#HandWashing remains the most basic and effective means to prevent the spread of infections.
Frequent #handwashing with soap under running water at home, work, health facilities, gatherings, and public spaces is highly important to stay healthy.
Let us all make #cleanhands a regular habit. It protects us all.
#TakeResponsibility
#HandWashing is a basic &effective tool against infections.
If we don't become sick, we would not need to use #antibiotics.
Let us promote the practice of #handwashing in our homes & communities to prevent #AntimicrobialResistance together.
#WorldAntimicrobialAwarenessWeek2022