В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
Chanel Tapper holds the Guinness World Record for the longest tongue — 3.8 in (9.75 cm) — and says she loves watching people shriek in disbelief. She can remove Jenga blocks, grab a lemon from a glass, flip plastic cups, lift a spoon by curling it, and touch her nose and chin with the tip.
[Read more]
👅✨😲
@googlefactss#weirdfacts#worldrecords#humanbody#nowyouknow#funfact
There is a naturally occurring metal called gallium that melts in your hand. It has a melting point of about 29.8°C (85.6°F), so just holding it makes it turn from a shiny solid into a silvery liquid. Gallium doesn’t react with air, so it can sit in your hand safely, but it can melt containers made of aluminum. Scientists use gallium in electronics, LED lights, and solar panels because of its unique properties.
[Read more]
@googlefactss
#Science#WeirdFacts#Chemistry#DidYouKnow#Materials#Innovation
In Death Valley’s Racetrack Playa, large rocks, some weighing hundreds of kilograms, move across the dry lake bed, leaving long tracks behind. This happens when a rare set of conditions align. First, rain fills the lake bed with a shallow layer of water. At night, the water freezes into thin sheets of ice. As the sun warms the ground, the ice breaks into large, floating panels. Light winds then push the ice, slowly moving the rocks across the playa. The tracks left behind can last for decades, creating unique patterns. This natural process has been understood by scientists and is one of the most fascinating geological phenomena.
🪨❄️🌞
[Read more]
@googlefactss
#Nature#WeirdFacts#Geography#DidYouKnow#Deserts#Science#Mystery
There is a volcano in Indonesia called Kawah Ijen that glows bright blue at night. The blue glow comes from burning sulfur gases that ignite as they escape from the crater. Miners work in the area collecting solidified sulfur, even though the fumes are toxic. The effect makes the crater look like a surreal, electric-blue river flowing through the volcano, attracting photographers and adventurers from around the world.
🌋🔵🔥
[Read more 1]
[Read more 2]
@googlefactss
#Nature#WeirdFacts#Volcanoes#DidYouKnow#Science#Adventure#Indonesia
There is a place in the Sahara Desert called the Richat Structure, also known as the “Eye of the Sahara.” It is a giant circular formation nearly 50 kilometers wide, visible from space. Scientists believe it formed from erosion, exposing layers of rock in concentric rings. The structure is perfectly round, which makes it look like a massive bullseye in the desert. It has fascinated explorers and geologists for decades because of its unusual shape.
🎯🏜️🌍
[Read more]
@googlefactss
#Geography#WeirdFacts#Nature#DidYouKnow#Desert#Earth#Landmarks
Mammatus clouds look like a sky full of hanging pouches or bubbles. Their name comes from the Latin word “mamma,” which means “breast,” because of their rounded, pouch-like shapes. These clouds often appear after thunderstorms and can be bright white, gray, or even orange during sunset. Despite their dramatic appearance, they are mostly harmless and form when cold air sinks into warmer air below, creating the pouch-like shapes.
☁️🌅🌩️
[Read more 1]
[Read more 2]
Show your own mammatus cloud pictures, the one with the most likes gets added to the post. 😉
@googlefactss
#Nature#WeirdFacts#Weather#DidYouKnow#Clouds#Atmosphere#Sky