В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🔥✨Unleash the Power of Aston Martin Valiant!✨🔥
Embark on a journey of power and precision with the Aston Martin Valiant, driven by a formidable 5.2-liter V12 engine with twin turbocharging, delivering an impressive 745 horsepower (compared to 715 in the Valour). Feel the exhilarating torque of 753 Nm propelling you forward with each twist of the throttle. Get ready to ignite your senses!
This fusion of power and performance is harnessed by an exclusive six-speed manual transmission, seamlessly transferring power to the rear wheels, creating an unmatched driving experience. Trust the Aston Martin Valiant to experience the exceptional blend of technology and emotion on the road.
Dive into the true embodiment of power, style, and automotive mastery with the Aston Martin Valiant!
#AstonMartin#Valiant#V12Power#Performance#DrivingExperience
🚗✨Introducing the Speedster 612 TR Teppista!✨🚗
This stunning masterpiece, based on the iconic Ferrari 250 Testarossa from 1957, is now available in the UAE for an astonishing 823 million rubles! 💰🇦🇪
🔍What makes it so special?
- Crafted in 2008 with a sleek carbon body that’s longer and wider than ever! 🖤
- Powered by a roaring V12 engine with a capacity of 5.7 liters! 🏎️💨
A true collector’s dream! 🌟
#Speedster612TR#Ferrari#LuxuryCars#CarCollector#UAE#AutomotiveArt#V12Power#Auto
✨ Introducing the Rolls-Royce Ghost Series II ✨
The updated sedan features a stunning new headlight design and an enlarged grille, reminiscent of the Spectre coupe! 🚗💎 The 22-inch wheels showcase fresh patterns, and a new deep blue shade joins the color palette. 🎨🔵
Inside, experience luxury with a unique bamboo-based fabric, crafted over a year! 🌿🛋️ The media system now operates on the advanced Spirit OS. 📱🎶
Under the hood, the powerful turbocharged V12 engine boasts 563 hp (591 hp in the Black Badge version) and is paired with an 8-speed automatic transmission for smooth rear-wheel drive. 💨⚙️
Elevate your journey with the Ghost Series II! 🌌
#RollsRoyce#GhostSeriesII#Luxury#AutomotiveExcellence#V12Power#Bespoke#EleganceOnWheels#Auto