В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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 all-new Honda Ye S7 electric crossover! 🌿
🔋 Two-motor powertrain: 476 hp total power. Front wheels driven by a 204-hp electric motor, while the rear wheels by a 272-hp motor.
🏞️ Built on the e:N Architecture W platform with independent suspension, this 4.7-meter crossover promises a smooth ride.
🔌 Co-developed with Dongfeng, the Ye S7 is set to redefine the electric SUV experience.⚡️
#HondaYeS7#ElectricCrossover#Innovation#Auto
🌟🚗 Introducing the Genesis GV90! 🚗🌟
Get ready for the flagship electric crossover from Genesis, set to debut this October! 🎉✨ Built on the innovative eM platform, an evolution of the E-GMP architecture, the GV90 promises an impressive 113 kWh battery that offers a remarkable range of up to 800 km!🔋🌍
With its luxurious design and advanced features, the GV90 will compete with premium full-size SUVs like the Range Rover. 🏞️👑🚀
#GenesisGV90#ElectricCrossover#LuxurySUV#eMPlatform#Auto🌐🔋✨
🚘✨Introducing the Skoda Elroq Electric Crossover!✨🚘
The new Skoda Elroq is slightly larger than the Karoq, measuring 4488x1884x1625 mm with a wheelbase of 2765 mm. With a ground clearance of 186 mm, it’s ready for any adventure! 🌍💪
⚡️Performance Features:
- Available with electric motors producing 170, 204, or 286 hp.
- The top all-wheel-drive version boasts an impressive 299 hp! 🚀
- Range: From 375 to 560 km on a single charge! 🔋🌿
✅Simply Clever Innovations:
- Tire tread depth gauge integrated into the ice scraper! ❄️
- Elastic net under the luggage shelf for convenient charging cable storage! 📦🔌
ℹ️ The petrol Karoq starts at €33,100 in Germany, while the Elroq will be just €760 more! 💰🇩🇪
#SkodaElroq#ElectricCrossover#SimplyClever#SustainableDriving#CarLaunch#Auto#Innovation#Skoda