В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🚗✨ Exciting News! The new Bentley Flying Spur is set to debut on September 10th! 🎉
This stunning sedan will feature the same V8 hybrid powertrain as the recently launched Continental GT. According to Bentley, it will be the "most powerful, dynamic, and economical four-door car in Bentley's 105-year history." 💪🌍
Stay tuned for more updates!
#BentleyFlyingSpur#LuxuryCars#HybridPower#Bentley#Auto
🚗✨ Exciting news! The updated Volvo XC90 is set to be unveiled on September 4th! 🌟
🔋 This refreshed model will feature a hybrid powertrain, ensuring it remains relevant until the brand transitions fully to electric vehicles by the end of the decade. ⚡️
Stay tuned for more updates!
#VolvoXC90#HybridPower#SustainableDriving#CarLaunch#Auto
🚗Introducing the upcoming McLaren P18!
🔥 Exciting news - this flagship supercar is set to be a 1000-horsepower all-wheel-drive hybrid! Only 399 lucky owners will get their hands on this beauty. 😍 Stay tuned for more details as clients have only seen a scale model of the design so far.
#McLarenP18#Supercar#HybridPower#AllWheelDrive#Auto🏁🔋🌟
🚗✨ Exciting news from McLaren! On October 6th, we might witness the unveiling of a brand new model that continues the legendary "1" lineage! 🌟
In a teaser video featuring the iconic F1 and P1, the date at the end hints at a thrilling reveal. 🔥
This hybrid supercar is set to deliver around 1000 hp, powered by a stunning V8 engine. 💪💨
Get ready for the next chapter in automotive excellence!
#McLaren#Supercar#HybridPower#ComingSoon#October6#Auto
🚗✨Introducing the Updated Audi A3 Hatchback: A Powerful Hybrid!✨🚗
⚙️ The heart of this beauty is the new 1.5 TFSI evo2 engine, replacing the previous 1.4-liter four-cylinder. With an increased compression ratio and higher fuel injection pressure, it's ready to impress! 💥
🔋 Coupled with a 116-hp electric motor, the 40 TFSI e variant produces a total of 204 hp and 350 Nm of torque, accelerating from 0 to 100 km/h in just 7.4 seconds! 🚀 Max speed? A thrilling 225 km/h! 🌟
🔥 For those craving more power, the 45 TFSI e variant boasts 272 hp and 400 Nm, hitting 100 km/h in just 6.3 seconds and a top speed of 237 km/h! 🏁💨
🛒 Orders are now open starting at €44,200!
#AudiA3#HybridPower#Innovation#LuxuryCars#CarEnthusiast#Performance#AudiLife#Auto🌍💚
🚗✨ Exciting News for BMW Fans!
The new BMW 5 Series Touring is here with electrified powertrains! ⚡️
Starting off, the lineup features a mild-hybrid 2.0L diesel engine. Now, it’s joined by a petrol alternative: a 2.0L engine paired with a 48V starter-generator, delivering 208 hp and 330 Nm. 🔥
Introducing the BMW 550e Touring: a full hybrid powerhouse with a 6-cylinder engine and an integrated electric motor in the 8-speed transmission, boasting an impressive 489 hp! 💪 On electric power alone, it can travel up to 90 km, reaching 0-100 km/h in just 4.4 seconds! ⏱️
And don’t miss the BMW i5 xDrive40 Touring! This all-electric beauty packs dual motors that deliver a total of 394 hp and 590 Nm. ⚡️🌍
#BMW#5Series#ElectricDriving#HybridPower#CarEnthusiast#LuxuryCars#Innovation#Sports🚘💚
🚗✨Introducing the BMW M5 Touring with M Performance Parts!🏁
BMW has unveiled stunning images of the new M5 Touring, now available with exclusive M Performance Parts! 🎉
This five-door beauty can be equipped with new aerodynamic body enhancements and a stylish alternative set of floor mats for the interior. Plus, an expanded range of accessories is now at your fingertips! 🛠️💎
Under the hood, the M5 Touring boasts a powerful hybrid powertrain delivering an impressive 727 hp and 1000 Nm of torque, allowing it to sprint from 0 to 100 km/h in just 3.6 seconds! ⚡️🚀 For those seeking even more thrill, the speed limiter can be raised to an exhilarating 305 km/h for an additional fee! 🏎️💨
#BMW#M5Touring#MPerformance#HybridPower#LuxuryCars#CarEnthusiasts#PerformanceParts#FastCars#Auto🚘🔥