В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🚗✨ The Final Pagani Zonda Unveiling! 🎉
On August 16, the last and 140th Zonda, named Arrivederci (Italian for "Goodbye"), will be revealed after 12 years of craftsmanship! 🇮🇹❤️
This stunning masterpiece features a full carbon fiber body, showcasing the pinnacle of automotive engineering. 🏎️💨
While details about the engine remain under wraps, it's likely to house the iconic 7.3L V12 from Mercedes-AMG, delivering a monstrous 760 hp and 780 Nm of torque! 🔥⚙️
#PaganiZonda#Arrivederci#Supercar#CarEnthusiast#AutomotiveArt#Auto🚀🌟
✨ Introducing the Rolls-Royce Spectre Lunaflair! 🌙
Engineered to capture the enchanting lunar halo effect, this stunning paint reflects sunlight through microscopic ice crystals in the atmosphere, creating a mesmerizing glow around the moon. 🌌
With a unique blend of seven layers of lacquer and pearlescent particles of magnesium and aluminum, the Spectre Lunaflair dazzles in both daylight and darkness. 🌟
This exclusive finish will not be replicated, making each vehicle truly one-of-a-kind! 🚗💎
#RollsRoyce#SpectreLunaflair#Luxury#AutomotiveArt#MoonlitMagic#ExclusiveDesign#Auto
✨ Introducing the Rolls-Royce Phantom Goldfinger! 🚗💨
In celebration of the 60th anniversary of "Goldfinger," this stunning long-wheelbase sedan is a tribute to the iconic film. 🎥💛
Featuring a color scheme reminiscent of the Phantom III Sedanca de Ville driven by the notorious Auric Goldfinger, this masterpiece is truly one-of-a-kind! 🌟
The iconic "Spirit of Ecstasy" is adorned with real gold, and there's even a hidden compartment holding a gold bar shaped like the Phantom! 🪙✨
Get ready to experience luxury like never before!
#RollsRoyce#PhantomGoldfinger#JamesBond#LuxuryCars#Goldfinger#AutomotiveArt#Elegance#Auto
🚗✨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
🚗✨SPOTTED: The Last Longtail Supercar - Pagani Huayra Codalunga!🌟
This stunning masterpiece, crafted in collaboration with the French luxury house Hermès, is one of only five ever made, each priced at a jaw-dropping €7 million! 💰💎
Inspired by the longtail sport prototypes of the 1960s, this special edition features an elongated rear and ditches the rear wing for a sleek design. The Mercedes-AMG V12 has been fine-tuned to deliver an astonishing 840 hp and 1100 Nm of torque! 🔥⚙️
A true work of art on wheels! 🖼️❤️
#Pagani#HuayraCodalunga#LuxuryCars#Supercar#CarSpotting#AutomotiveArt#Hermes#V12#CarEnthusiast#ExoticCars#Auto🚀🌍