В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
#Iceland🇮🇸
A special place in Iceland is considered to be the black beach. It was here that such cult movies as "The Lord of the Rings", "Game of Thrones" and "Star Wars" were filmed. The black beach was formed as a result of volcanic activity. This event happened many years ago
#Iceland, Gudlfoss 🇮🇸
Gyudlfoss is a waterfall in Iceland, in the Syudurland region.
The depth of the waterfall to the place of water falling in the valley is about 70 meters. The Güdlfoss itself consists of two steps - 21 meters and 11 meters high, dumped to each other at an angle of 90 °.
It is considered one of the most beautiful places in Iceland and is the most visited tourists.
🌟Breathtaking Views of Iceland!
🟠A mesmerizing landscape where a powerful waterfall meets silent green hills and dramatic clouds on the horizon.
🟠Nature here stuns with its beauty and scale, offering perfect spots for adventure seekers and photography enthusiasts. Feel the grandeur and tranquility of these magnificent landscapes!
#Iceland | @voyage
🗺 Iceland 🇮🇸
Following a recent volcanic eruption, the main highway to the Icelandic town of Grindavík is now impassable, and the surrounding area is covered in lava for several kilometers.
#Iceland | @voyage
Iceland🇮🇸
🟠A canyon located in the Jokuldalur Valley, Iceland.
🟠It is famous for its columnar basalt formations and blue-green water.
#Iceland | @voyage
Iceland🇮🇸
🟠A canyon located in the Jokuldalur Valley, Iceland.
🟠It is famous for its columnar basalt formations and blue-green water.
#Iceland | @voyage
Iceland 🇮🇸
🟠After the eruption of Eldfell volcano on Heimaey Island, a stunning natural wonder emerged — a rock formation shaped like an elephant drinking from the Atlantic.
📏
📏
📏
📏
📏
📏
📏
📏
#Iceland | @voyage
⚡️Hallgrímskirkja – a majestic church in the heart of Reykjavík! ✨🏔️
🟠Inside, it houses a massive pipe organ with 5,275 pipes, standing 15 meters tall and weighing 25 tons – a true musical masterpiece!
📏
📏
📏
📏
📏
📏
📏
📏
#Iceland | @voyage
✨ Hallgrímskirkja — the highest point in Reykjavik.
🟠Imagine a majestic church rising above the city like a guardian of time. Its unique architecture and panoramic views of Reykjavik make it a must-visit place.
📏
📏
📏
📏
📏
📏
📏
📏
#Iceland🇮🇸@voyage