В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
🔖 How Ukraine’s killer drones are beating Russian jamming | Hacker News #pinboard#warfare
As an engineer, I am fascinated by it all. As a human, I am horrified that we democratized violence on this scale.
A missile worth perhaps a million dollars can kill maybe 12 or 20 people. But for one million dollars, you can buy 10,000 drones, put four grenades on each, and they will kill 1,000 or even 2,000 people or destroy 200 tanks.
https://news.ycombinator.com/item?id=44168658
🚨🇺🇸TRUMP: IRANIAN OPERATIONS WILL END "VERY SOON" BUT NOT THIS WEEK
🔹 11 days of military action have dismantled Iran's radar, telecommunications, leadership, missile stockpiles, and navy 💥
🔹 US forces destroyed 10 Iranian mine-laying vessels in Strait of Hormuz yesterday — key route for 20% of global oil 🛢️
🔹 Defense Secretary Hegseth calls March 10 "most intense" day of bombardment — 140 US troops wounded, 7 killed ⚰️
🔹 President warns "death, fire, and fury" if Tehran disrupts shipping lanes — tensions escalating 🔥
The Commander-in-Chief knows exactly what he's doing 😤💪
#USNews#MiddleEast#warfare
@america
🌎 Ancient Greek fire, known as "Greek fire," was a weapon that could burn even on water. This flammable liquid, projected from tubes, terrified enemies at sea and kept its formula a closely guarded secret, lost to history. ✨
#history⚡#chemistry⚡#warfare
👉subscribe Interesting Planet
📢 Ukraine's defense forces resort to using Leopard tanks as long-range artillery, failing to fulfill their intended purpose against Russia. The highly anticipated offensive has turned into a defensive strategy, with the giant tanks deployed along the front line. But will this change the course of the conflict? Meanwhile, Poland plans to provide Ukraine with additional armored firepower. The war continues... 💥#Ukraine#Russia#LeopardTanks#Warfare
https://www.gazeta.ru/army/news/2023/12/05/21855127.shtml
Subscribe to @BadVolfNews