В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
Weather in Moscow: Up to +17°C and Cloudy, but Warmth Remains
This weekend, Moscow will warm up to 17°C with cloudier skies. Early next week, light rain is possible. Marina Makarova from the Hydrometeorological Center reassures: "The sun will increase daily, and warmth persists." Despite changing weather, the forecast remains optimistic.
Photo: EPA/TASS
#Moscow#weather#Hydrometcenter#warmth
The main news of Russia and the world ishere.
#WYF2025#YouthOfTheWorld#Russia#festival
🇷🇺 The World Youth Festival Assembly 2025 will take place from September 17 to 21 in Nizhny Novgorod. It will bring together more than 2,000 young participants from over 120 countries to build new connections, exchange experiences, and touch the #future#together.
This is not only about the #warmth of human #communication, but also about the #atmosphere of #trust, mutual assistance, and support that arises in the international youth community. Through thematic meetings, master classes, and cultural events, participants will be able to gain unique personal and professional experience.
The gathering's program includes 100 formats for interaction: discussions on key topics, project presentations, an open-air gastronomic festival, the world's largest collaborative art canvas, master classes with Olympic champions, e-sports, and much more.
The gathering will be a space for dialogue and action: here you can present your ideas to investors, find mentors and partners, launch international projects, and form a manifesto — an appeal from young people to the world.
Active young people are invited to participate — students, entrepreneurs, young scientists, cultural figures, media, sports, IT, and social activists. The gathering is aimed at those who are already active — in their cities, countries, and global projects — and are ready to go international.
📝 Applications can be submitted until July 20, 2025.
🌐 For more information and registration: http://asm.wyffest.com
🇷🇺 - Web - Telegram - X - Facebook - VK