В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🚗 Exciting news from Toyota!
🚀 The GR86 sports car has been enhanced for even better handling, and a new special edition has been released! All GR86 models now feature recalibrated shocks, updated stability systems, and improved steering assistance. Manual transmission models get a more responsive throttle control, while automatic models benefit from optimized transmission logic.
Introducing the special RZ Ridge Green edition!
💚 This exclusive version boasts a unique green body color with bronze wheels and a premium interior finish of leather and Alcantara. Equipped with Brembo brakes and Sachs shocks as standard. Only 200 of these sports cars will be produced, so the right to purchase will be determined by a lottery🔥
#Toyota#GR86#RidgeGreen#SpecialEdition#LimitedRelease#Sportscar#Auto😍
🚀 AI TRENDS | OpenAI to Limit Release of Advanced Cybersecurity Model
OpenAI is reportedly developing an advanced cybersecurity model, which it plans to release only to a select group of companies, according to a source familiar with the matter. This approach mirrors Anthropic's limited release of its Mythos model. According to Jin10, the capabilities of artificial intelligence have reached a critical point, particularly in terms of autonomy and hacking potential. Model developers are increasingly concerned about the potential misuse of their tools, leading to reluctance in making them widely available. On Tuesday, Anthropic announced that due to concerns over its advanced hacking capabilities, it would restrict access to its new Mythos preview model to a select group of technology and cybersecurity companies. Anthropic is the first AI company to adopt this approach with a new model. The source indicated that OpenAI is now planning to implement a similar strategy.
#AItrends#OpenAI#cybersecurity#advancedmodel#limitedrelease#Anthropic#Mythos#AIautonomy#hackingpotential#technology#AItools#modelrelease