В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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 stunning Pagani Utopia Roadster! 🌟
This masterpiece trades its traditional roof for a removable panel featuring a sleek glass insert. 🪟 For those who prefer a classic touch, there’s an alternative fabric top that neatly stores in its own case. 🎒
With no need for extra reinforcement, the Utopia's inherent strength shines through in this exquisite design. 💪
Under the hood, this beauty packs a powerful punch with an 864-hp V12 engine from Mercedes-AMG! 🔥💨
Get ready to own this automotive marvel for a cool €3.1 million! 💰
#PaganiUtopia#Roadster#Supercar#Auto#CarEnthusiast#DreamCar#ExoticCars#Pagani
🚙✨For Sale: Brabus 900 XLP!✨🚙
Get ready to own a masterpiece! This exclusive pickup, built on the Mercedes-AMG G 63 platform, boasts a staggering 900 horsepower and only 10 units produced! 🚀
📍Mileage: 3,375 km
💰Price: Nearly $1 million
Under the hood, it features a custom-built engine based on the stock V8, with an increased displacement of 4.5 liters, custom turbocharging, and upgraded components for unmatched performance! 🔥
#Brabus900XLP#LuxuryCars#ForSale#SuperPickup#CarEnthusiast#ExoticCars#MercedesAMG#DreamCar#Auto
🚗💨Unleash the Beast: 1600 HP Lamborghini Aventador SVJ!🦙🔥
For those who crave power and performance, Underground Racing Motors is offering a jaw-dropping 1600-horsepower Lamborghini Aventador SVJ for just $1.7 million!💰✨
Originally launched over six years ago, the Aventador SVJ boasts a naturally aspirated 6.5L V12 engine producing 770 HP and 720 Nm of torque. But with the magic of twin-turbocharging and expert tuning, this beast can roar up to an astonishing 1600 HP when fueled with race gas! 🏁💥 On regular gasoline, it still impresses with 1250 HP!
#Lamborghini#AventadorSVJ#UndergroundRacing#Supercar#CarEnthusiast#LuxuryCars#TurboPower#Hypercar#DreamCar#Auto
🚗✨For Sale: Aston Martin Vanquish!✨🚗
This stunning grand tourer isn't just any car; it was featured in a promotional photoshoot for the James Bond film "Die Another Day" starring Pierce Brosnan! 🌟
🔹Power: 460 HP
🔹Mileage: Over 60,000 km
🔹Price: Up to $100,000
Don't miss your chance to own a piece of cinematic history! 🎬💎
#AstonMartin#Vanquish#JamesBond#DieAnotherDay#LuxuryCars#CarForSale#BondCar#DreamCar#Auto
🏎 Get your hands on a piece of history! 🌟
Rare Lamborghini Countach LP400 up for auction! Previously owned by musician Rod Stewart.
Only around 150 LP400 Countach models were ever produced by Lamborghini, featuring a 3.9-liter V12 engine with 370 horsepower. Rod Stewart was the proud first owner of this incredible car, purchasing it in Australia during his tours and then bringing it back to the UK.
💲 Price: $520,000 💲
⏳ Only one day left until the end of the auction! ⏳
#Lamborghini#Countach#LP400#RodStewart#RareCar#MusicianOwned#Auction#DreamCar#MuscleCar#Legendary#CollectorCar