В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
#phrases
💥Shallow matters
⚜The term "shallow matters" refers to topics, discussions, or concerns that lack depth, seriousness, or
significance. They are often superficial and do not engage with deeper issues or complexities.
⚜While many people were debating the impact of climate change, Sarah seemed more interested in the shallow matters of which celebrity was dating whom."
#Phrases
💢To cry out for
💠To be in desperate need of something
📝Note:- 📝
the subject is generally not a person, but an organisation, object or situation
🌀 Example:-
A:- This room is crying out for some colour and modern furnishing. I suggested subtle green wallpaper, but it didn’t register with Jenny. On second thoughts, maybe red?
B:- RED? You've definitely got a screw loose.
#Phrases
💢 A chink in one’s armour
💠One small weakness in a person or their argument which makes them open to attack or criticism
🌀 Example:-
Our lawyers have been sifting through the evidence but cannot find a chink in the defending company’s armour. It’s no wonder they are being very woolly on how they intend to present our case in court.
#phrases
⚜Prepositional phrase
🔅Until all hours
▪️(informal) Until very late; until the small hours.
▪️I used to stay up until all hours watching television.
#phrases
⚜Hear oneself think
◐To engage in mental activity without being distracted by noise.
◐Please turn down that music. I can hardly hear myself think.