В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
📍 Nighttime in Singapore 🇸🇬
View of the Marina Bay Sands hotel 🌆
Singapore is an island nation in Southeast Asia. Founded as a British trading colony in 1819, after gaining independence it became one of the most prosperous countries, with the world's leading trading port.
A fascinating fact: Singapore is the world's only island city-state! 🏙️🌴
#travel#wanderlust#cityscape
🌍 Hong Kong’s extensive network of elevated walkways—some stretching over 800 meters—lets people travel between major buildings without ever touching the street, maximizing space in the crowded city. ✨
#urban⚡#planning⚡#cityscape⚡#infrastructure⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌴Victoria Embankment in Durban is one of the city’s most iconic waterfront areas — both a major transport route and a symbol of urban identity. 🌆
📍 Along the Embankment you’ll find:
🔹 the famous John Ross House with the Roma Revolving Restaurant
🔹 Durban’s city hall and court buildings
🔹 the historic yacht basin
🔹 monuments, greenery, and sweeping views of the bay
🚶♀️ It’s a perfect place for walks, photos, and taking in the rhythm of Durban’s harbor life — where colonial history meets modern African energy.
📹 Video
#Durban#VictoriaEmbankment#SouthAfrica#Cityscape#Waterfront#History#UrbanAfrica#TravelSouthAfrica#Architecture#JohnRossHouse#ExploreDurban
Discover Tashkent in autumn over the decades. From Petrov’s paintings to Soviet and modern photography, see how Uzbekistan’s capital evolved.
https://yep.uz/en/2025/09/tashkent-autumn-20th-21st-century/
#tashkent#autumn#vladimirpetrov#paintings#sovietphotography#20thcentury#21stcentury#cityscape#history#uzbekistan