В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
#Tourist
The Great Wall of China :
is a huge chain of defensive fortifications stretching across northern China, it is a symbol of China and one of the Seven Wonders of the new world, known for its enormous length exceeding 21 thousand kilometers, it was built over centuries, especially during the Ming dynasty, it features watchtowers and strategic corridors, it is a UNESCO World Heritage Site and an outstanding world tourist destination.
📝
Construction history:
the first construction work began more than 2000 years ago, during the spring and autumn reign and the Warring States, and it was significantly expanded and renovated by later dynasties, especially the Ming Dynasty (1369-1644).
#Nature
#Tourist
Socotra:
is a Yemeni archipelago belonging to the Hadramaut region consisting of six islands on the Indian Ocean off the coast of the Horn of Africa near the Gulf of Aden, located about 240 kilometers (150 Mi) east of the coast of Somalia and 380 kilometers (240 Mi) south of the Arabian Peninsula.
The island was classified as a World Heritage Site in 2008, and the New York Times ranked it as the most beautiful island in the world in 2010 due to the unique biodiversity and environmental importance of this island and its reflection on the world. In October of 2013, the Socotra archipelago governorate became an independent governorate from Hadramaut governorate.
#History
#Tourist
The Great Sphinx:
is a huge stone sculpture carved from limestone, embodying a mythical creature with a human head and the body of a lion in a reclining position.
Facing directly from West to East, the statue is located on the Giza plateau on the West Bank of the Nile in Giza, Egypt.
It is believed that the facial features of the statue belong to Pharaoh Khafre.
The original figure of the Sphinx was carved from the Adim Rock, later it was restored with limestone layers. The statue is 73 M (240 ft) long from claw to tail, 20 M (66 ft) high from the base to the top of the head, and 19 m (62 ft) wide at its hind feet