В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
Did you manage to catch these pastel-coloured altocumulus clouds at sunset?
When the sun is at a low angle on the horizon, sunlight travels across a longer distance through the atmosphere before reaching our eyes. As a result, blue colours are scattered by atmospheric particles, leaving behind brilliant hues of pink, orange and yellow.
📷: peiqiitohh #SGWeathergrams#WeatherWednesday
If you were in the Newton area on 25 May, you may have spotted this huge woolly blanket in the sky!
This blanket of dense clouds was formed as the top of a cumulonimbus cloud collapsed following strong thunderstorms across Singapore earlier that morning.
Named “cirrus spissatus”, these rarer upper atmosphere clouds are thicker and denser, and would block out the sun. The Latin word “spissatus” in its name describes its thicker appearance.
📷 Photo by _quietude__ #SGWeathergrams#WeatherWednesday
The mesmerising patterns formed by these beautiful stratocumulus clouds, seem to be reminding us to keep a safe distance from each other as we go about our daily activities. Tag us in your #SGWeathergrams on Instagram so that we can share your beautiful captures with others! #WeatherWednesday
📷: infectiousj
Hello Halo! Did you spot it this afternoon? These faint coloured rings encircling the sun are formed by the refraction of the light through ice crystals in high-level clouds under relatively clear conditions. #SGWeathergrams#SGWeather
While an impending thunderstorm looms, blue skies and fluffy clouds shine through in the distance. Tag us in your #SGWeathergrams posts on Facebook & Instagram so we can share it on #WeatherWednesdays. :)
📷: siewjunjie
#WeatherWednesday#throwback to the sunrise on 17 Jun, when we were greeted by this beautiful scattering of cirrocumulus stratiformis clouds.
The Latin word “stratiformis” means “stretched out”, referring to its irregular, dotted, blanket-like appearance.
📷 Photo by knifematchneedle #SGWeathergrams