В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🚘 Skytop with "the most powerful V8 engine ever" unveiled
The latest BMW Skytop has made its debut at the Villa d'Este 2024 classic car show on the shores of Lake Como.
The two-seater car has a rigid roof that can be removed manually and the rear window can be raised and lowered with a button. "Chrome shadow effect" is designed specifically for the Skytop.
According to the manufacturer, the car has been given the "most powerful V8 engine", which is supposedly the same 4.4-litre 625bhp engine used in the M8 Competition.
In creating the Skytop, BMW decided to pay homage to the brand's classic models such as the Z8 and 503. Although the car is only a concept car at the moment, BMW has not ruled out the possibility of a limited production run.
@CarsNews
#BMW#conceptcar#roadster
✨ Presenting the Cadillac Sollei convertible with a stunning mushroom-based interior! 🍄
This concept, based on the production platform of the electric Celestiq, features a unique body design and interior finish using five different wood types and the bio-material Fine Mycelium, including mushroom mycelium.
The Sollei showcases the revival of the classic Manila Cream color from the late 1950s. While specific technical details are yet to be revealed, the production Celestiq is equipped with electric motors producing around 600 horsepower.
#Cadillac#Sollei#Celestiq#ElectricCar#Auto#ConceptCar🚗💫
🚗✨ Introducing the Alpenglow Hy6 by Alpine! 🌟
This stunning concept car is the evolution of the Alpenglow Hy4, showcasing a powerful V6 engine that delivers an impressive 730 hp and 770 Nm of torque—all powered by hydrogen! 💨🔋
Built on a lightweight carbon LMP3 chassis, the Hy6 promises thrilling performance and cutting-edge technology. Production is on the horizon, with the possibility of an all-electric powertrain on the assembly line! ⚡️🌍
#Alpine#AlpenglowHy6#HydrogenPower#ElectricFuture#CarEnthusiast#ConceptCar#Innovation#Auto🚀