В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🌟🚗Introducing the Pininfarina B95 Gotham!🦇✨
Inspired by the legendary hero Bruce Wayne, this hypercar is designed for those who dare to push the limits! 💪🔥
Featuring the iconic Wayne Enterprises logos, the B95 Gotham showcases a stunning design that embodies the spirit of Gotham City. 🏙️🖤 On the driver's door, you’ll find the powerful quote: "All men have limits... I ignore mine." — a true testament to the Dark Knight’s relentless pursuit of excellence. 🗣️💬
The car's displays come alive with custom graphics, and even the virtual assistant speaks in the voice of Alfred Pennyworth, bringing a touch of elegance and sophistication to your driving experience. 🎩🤖
And this isn’t just a show car! A limited number of these masterpieces will be produced by order. Don’t miss your chance to own a piece of superhero history! 🌌🚀
#Pininfarina#B95Gotham#BruceWayne#Hypercar#Auto🖤🔧
🚗✨ Introducing the Unique Pininfarina Battista Targamerica! 🌟
Pininfarina has unveiled a stunning roadster, the Battista Targamerica, crafted for a special client who already owns the Battista coupe. This exclusive model features a sleek convertible design with a refined rear end. 🌈🛠️
One of the standout elements of the interior is a bespoke cigar holder and humidor, specially made for this one-of-a-kind vehicle. The custom aluminum and glass case can hold up to three cigars, adding a touch of luxury to every drive. 💨💼💨
Under the hood, the Battista Targamerica boasts the same incredible four-motor powertrain as the Rimac Nevera, delivering a jaw-dropping 1900 horsepower!⚡️💥 It accelerates from 0 to 60 mph in under 2 seconds!🚀🔥
This masterpiece is not just a car; it's an experience!
#Pininfarina#BattistaTargamerica#LuxuryCars#Roadster#CustomDesign#CigarLovers#ElectricSupercar#Performance#Auto🚗💖