В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
@redfoxuz / #rebranding#restyling
Facebook o'zini aydentikasini yangiladi
Xabaringizbo'lsa 3-4 kun oldin facebook logosi yangilangani haqida xabarlar bo'lganedi, endi esa aydentikasi ham yangilandi
Batafsil: https://design.facebook.com/stories/redefining-facebooks-brand-identity/
@redfoxuz / #rebranding#restyling
Instagram o'z brendini restayling qildi!
Yangi shrift, gradient rangi yanada yorqinlashgan. Yangi shriftdan tashqari "wordmark" va dastur ikonkasi yangilangan
Batafsil: https://about.instagram.com/brand
Restayling haqida qanday fikrdasiz?
📰 New Mercedes-Benz G-Class has received a retroversion
A total of 460 of these SUVs will be produced.
💪 The Mercedes G-Class 2025 lineup features an exclusive Stronger than the 1980s version inspired by the early Gelendwagen models.
🔎 The exterior differs due to black bumpers, underbody protection, orange turn signals, wheel rims and roof rack. The body colors are borrowed from the models of the 80s. The interior combines expensive Nappa leather and checkered fabric, and on the front panel there is a plate with the serial number and the inscription Stronger than the 1980s.
🐎 The models are offered with 3.0-liter turbo engines: G500 – 449 hp, G450 d – 367 hp.
💰 The price starts from $203,000.
@CarsNews
#Mercedes#restyling
🚘 has unveiled a Phantom Goldfinger car with a hidden gold bar in the cabin
🎂 The sedan was created for the 60th anniversary of Goldfinger – a film about James Bond. In the film, a millionaire criminal smuggles gold. He smelts gold and makes it into parts for his Rolls-Royce Phantom.
🔎 The modern Phantom received a golden-black body paint, repeating the colour scheme of the car from the film, and many other references to the film. For example, the signature nose piece ‘Spirit of Ecstasy’ looks as if it was made of pure gold, which for disguise was covered with silver, partially erased. In fact, the opposite is true: the mascot was made of silver and plated with an uneven coating of 18-carat gold.
@CarsNews
#RollsRoyce#Bespoke#restyling