В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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 for BMW fans! The new BMW M5 Touring will be unveiled on August 15 at Pebble Beach.
This innovative model will hit the US market in spring 2025, marking the first official M5 Touring available in the country.
Stay tuned for more updates!
#BMW#M5Touring#PebbleBeach#CarLaunch#Auto
🚗✨Introducing the BMW M5 Touring with M Performance Parts!🏁
BMW has unveiled stunning images of the new M5 Touring, now available with exclusive M Performance Parts! 🎉
This five-door beauty can be equipped with new aerodynamic body enhancements and a stylish alternative set of floor mats for the interior. Plus, an expanded range of accessories is now at your fingertips! 🛠️💎
Under the hood, the M5 Touring boasts a powerful hybrid powertrain delivering an impressive 727 hp and 1000 Nm of torque, allowing it to sprint from 0 to 100 km/h in just 3.6 seconds! ⚡️🚀 For those seeking even more thrill, the speed limiter can be raised to an exhilarating 305 km/h for an additional fee! 🏎️💨
#BMW#M5Touring#MPerformance#HybridPower#LuxuryCars#CarEnthusiasts#PerformanceParts#FastCars#Auto🚘🔥
🚗💨 Introducing the BMW M5 Touring! 💨🚗
BMW has officially unveiled the stunning M5 in Touring body style!🌟
Under the hood, it boasts a powerful V8 twin-turbo engine with an impressive total output of 727 horsepower!🔥💪
With the rear seats folded down, you can fit a whopping 1.6 cubic meters of cargo! 🧳📦 And it can sprint from 0 to 100 km/h in just 3.6 seconds!⏱️⚡️
Weighing in at 2508 kg, this beauty is slightly heavier than its sedan counterpart. 🚙✨ This is only the third generation of the M5 in this body style and the first to hit the US market! 🇺🇸
Prices start at $121,500.💵
Get ready for an exhilarating ride! 🏁
#BMW#M5Touring#SportsCar#V8Power#LuxuryPerformance#CarEnthusiast#FastCars#Auto#BMWM🚘🌍