В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🌎 Australian megafauna like Diprotodon, the largest marsupial ever, disappeared about 46,000 years ago. These giant wombat relatives weighed up to 2,750 kilograms. The cause of their extinction is debated—some studies suggest climate shifts, while others blame human hunting. Diprotodon fossils have been found at over 100 sites across Australia. ✨
#extinctanimals⚡#megafauna⚡#paleontology
👉subscribe Interesting Planet
👉more Channels
🌎 The mysterious extinction of the “Siberian unicorn,” or Elasmotherium sibiricum, puzzles paleontologists. This massive Ice Age mammal, related to modern rhinos, had a large forehead horn and grazed Eurasian steppes. DNA studies show it survived until about 39,000 years ago—much later than once thought. ✨
#extinctanimals⚡#paleontology⚡#iceage
👉subscribe Interesting Planet
👉more Channels
🌎 The woolly rhinoceros, Coelodonta antiquitatis, roamed Ice Age Eurasia with a thick fur coat and massive horn. Fossils found in Siberian permafrost show it survived extreme cold; its extinction about 14,000 years ago is linked to climate warming and human hunting. ✨
#extinctanimals⚡#paleontology⚡#iceage
👉subscribe Interesting Planet
👉more Channels
🌎 The giant short-faced bear, Arctodus simus, roamed North America during the last Ice Age. Standing up to 1.5 meters at the shoulder, it was one of the largest terrestrial mammalian carnivores ever, yet paleontologists debate if it was mainly a predator or a scavenger. Fossils suggest it vanished around 11,000 years ago, along with much other megafauna. ✨
#extinctanimals⚡#paleontology⚡#iceage
👉subscribe Interesting Planet
👉more Channels
🌎 The Siberian unicorn, or Elasmotherium, was a massive prehistoric rhinoceros with a single huge horn on its forehead. Fossils show it roamed Eurasia until about 39,000 years ago, much later than once believed. ✨
#extinctanimals⚡#paleontology⚡#iceage
👉subscribe Interesting Planet
🌎 The thylacine, or Tasmanian tiger, was a striped marsupial predator native to Australia and Tasmania. Despite reports of sightings, the species was declared extinct in 1936 after the last known individual died in captivity. Intensive searches and camera traps have never produced concrete evidence of survival, but mystery sightings continue to spark debate among biologists. ✨
#extinctanimals⚡#marsupials⚡#australia
👉subscribe Interesting Planet