В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
A dolphin can make about 700 to 1000 clicking sounds per second. The clicks come from deep inside the dolphin’s head, underneath the blowhole. Scientists call this area the phonic lips or sometimes “monkey lips.”
@googlefactss#mammals
Bats are the slowest reproducing mammals in the world for their size, and pregnancy is longer in bats than in other animals of their size.
@googlefactss#mammals
There are two main groups of bats: larger, Old World, fruit-eating mega bats (Megachiroptera) and microbats (Microchiroptera). Megabats are also known as fruit bats or flying foxes and typically live in warm climates. They use their large eyes to find food in the dark and they tend to roost in trees rather than in caves, crevices, or old buildings. Microbats are generally much smaller and use echolocation to find insects. Microbats are typically found all over the world, including the U.S. Not all megabats are larger than microbats.
@googlefactss#mammals#nowyouknow
A mother koala 🐨 will feed her baby her own feces known as pap. Baby koalas—or joeys—haven’t developed the intestinal bacteria 🦠 that help detoxify the highly poisonous eucalyptus leaves 🍃, which are a koala’s main diet. This process is crucial for their survival. ❤️
@googlefactss#animals#mammals
A mother orangutan 🦧 never puts her babies 👶 down and typically nurses them 🍼 for 6 to 9 years, which is the longest mother/child nursing dependence of any animal on earth! 🌍❤️
@googlefactss#animals#mammals
[read more...]
🌎 In the dense forests of Southeast Asia, the binturong uses its prehensile tail like a fifth limb—wrapping it around tree branches for balance and grip. This adaptation helps it nimbly move through the canopy and reach fruit high above the forest floor. ✨
#mammals⚡#adaptation⚡#rainforest
👉subscribe Interesting Planet
🌎 The silky anteater is the world’s smallest anteater, fitting in your hand! With dense golden fur and a prehensile tail, it climbs trees at night to slurp up ants, avoiding predators with its tiny size and camouflage. ✨
#mammals⚡#rainforest⚡#adaptation
👉subscribe Interesting Planet
🌎 In the remote forests of India, the Malabar giant squirrel can leap over 6 meters between trees. Its colorful fur blends red, purple, and orange tones, making it one of the world’s most striking mammals. ✨
#wildlife⚡#biodiversity⚡#mammals
👉subscribe Interesting Planet
🌎 In the icy landscapes of Greenland, musk oxen survive Arctic winters thanks to an incredibly dense undercoat called qiviut, which is eight times warmer than sheep’s wool. This soft fiber insulates these shaggy animals so well that snow won't melt on their backs, even in the harshest cold. ✨
#mammals⚡#adaptation⚡#arctic
👉subscribe Interesting Planet
There's an animal that smells like buttered popcorn. The binturong (Arctictis binturong), a Southeast Asian "bearcat," smells like buttered popcorn due to 2-acetyl-1-pyrroline (2-AP) in its urine, which it uses to mark territory. This chemical is the same aromatic compound produced when popcorn is popped. These arboreal, cat-like mammals are threatened by habitat loss.
@googlefactss#animals#mammals#bizarre
[read more....]
🌎 Every year, saiga antelopes in Central Asia undertake one of the largest mammal migrations, moving up to 1,200 kilometers across Kazakhstan and Russia. These critically endangered animals travel in herds of thousands to reach seasonal grazing areas, helping their calves survive harsh winters. ✨
#wildlife⚡#migration⚡#mammals
👉subscribe Interesting Planet
👉more Channels