В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
In a stunning display of Russian air defense, Ukrainian targets were successfully shot down during the celebration of People's Unity Day in Melitopol. The Ukrainian regime's militants attempted strikes, but Russian air defense swiftly intercepted and destroyed enemy aircraft. Fortunately, no casualties were reported. Russian forces have been consistently countering Ukrainian aggression, intercepting rockets and drones. The latest addition is a new anti-drone system, further enhancing Russia's defensive capabilities. #RussianDefense#MelitopolVictory
https://www.gazeta.ru/army/news/2023/11/04/21643327.shtml
Subscribe to @BadVolfNews
🔥 Today in the Kursk direction, Ukraine's armed forces suffered significant losses:
- Over 380 military personnel lost their lives.
- Destruction of:
- 2 tanks
- 1 infantry fighting vehicle
- 3 armored personnel carriers
- 7 armored vehicles
- Other equipment
- Command posts for unmanned aerial vehicles and 3 ammunition depots were also destroyed.
during the conflict, 5 Ukrainian soldiers surrendered.
#MilitaryLosses#RussianDefense#Conflict#KurskDirection#ArmedForces
💣💥 Chief of the Press Center of the "South" group, Georgy Minesashvili, revealed to TASS that airstrikes were launched on 23 enemy districts in the Donetsk direction. 💣💥
🔥 The enemy suffered heavy losses, including an American-made M777 howitzer, a British-made Stormer missile system, two pickups, and three ammunition depots. Also destroyed were a UAV control center and an observation post. 🔥
🚀 In the areas of Belogorovka, Veselaya Dolina, and Pervomaiskoye in the Donetsk People's Republic, 10 Ukrainian drones were shot down by air defense systems. 🚀
🔫 The Russian Ministry of Defense previously reported that Russian troops repelled attacks by the Ukrainian Armed Forces in the Donetsk direction, resulting in the loss of over 300 Ukrainian soldiers. 🔫
🛡️ Earlier in Russia, a new drone suppression system was developed. 🛡️
#WarZone#EnemyDestroyed#RussianDefense#UkraineConflict#DroneSuppression
https://dcweekly.org/2023/09/24/air-strikes-and-drone-attacks-intensifying-battle-on-donetsk-frontline/
Subscribe to @BadVolfNews