В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🚗✨Nissan Unveils the Updated Frontier Pickup!🌟
Get ready for the all-new look of the Nissan Frontier, designed specifically for the North American market! 🇺🇸💪
🔧What's New?
- Fresh exterior design for a bold presence!
- Upgraded media system with a larger screen for an enhanced driving experience! 📱🎶
- Expanded features to keep you connected and comfortable!
⚙️Under the Hood:
No changes here! The Frontier continues to boast a powerful 3.8-liter V6 engine with 310 horsepower and a smooth 9-speed automatic transmission! 🚀
#NissanFrontier#PickupTruck#NewRelease#AutomotiveNews#V6Power#Auto
🚀 Exciting News: The Lamborghini Huracan Successor is Here! 🔥
Images of the highly anticipated Temerario have leaked online, and it looks stunning without any camouflage! 😍
🔹 Say goodbye to the atmospheric V10 and hello to a powerful V8 twin-turbo engine! 💨
🔹 Get ready for an impressive 900 horsepower with hybrid electric enhancements! ⚡️💪
This beast promises to deliver an exhilarating driving experience like no other! 🏎️💨
#Lamborghini#Temerario#HuracanSuccessor#V8Turbo#Supercar#AutomotiveNews#Auto
🚗✨ Exciting news from Hyundai! They're set to unveil a mysterious new sports car at the upcoming N Day event on October 25th! 🎉
🔍 One theory suggests that they’ve developed a "charged" version of the compact crossover Inster, debuting either as a concept or as a production model. Another hypothesis hints at multiple new releases during the event! 🤔💥
#Hyundai#NDay#SportsCar#Inster#CarReveal#AutomotiveNews#Auto
🚗💨 Exciting news for hot hatch enthusiasts! Toyota has upgraded the GR Corolla! 🎉
🔧 The 1.6L engine now packs a punch with 304 horsepower and increased torque from 370 to 400 Nm! 💪
⚙️ Plus, an 8-speed automatic transmission is now available as an alternative to the standard manual! 🏎️
✨ The chassis has been reinforced, and the exterior has received some stylish tweaks! 😍
🛒 Sales are set to start this winter, but prices are yet to be announced!
#Toyota#GRCorolla#HotHatch#CarEnthusiast#AutomotiveNews#PerformanceCar#Upgrade#Auto
🚗✨ Dacia Sandero: The Best-Selling Car in Europe! 🌍🎉
In just six months, 143,596 units of this budget hatchback have been sold across the continent! 🥇💰
🏆 Top 3 Best-Sellers:
1️⃣ Dacia Sandero - 143,596 units
2️⃣ Volkswagen Golf - 126,993 units
3️⃣ Renault Clio - 114,623 units
📉 Former champion Tesla Model Y has slipped to eighth place.
Congratulations to all the winners! 🥳🚘
#DaciaSandero#BestSellingCar#Europe#AutomotiveNews#CarSales#Volkswagen#Renault#Top10Cars#Auto