В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
📰 Another Gun, Another Perimeter: Mar-a-Lago Turns Into a Crime Scene Again
An armed man in his early 20s was shot dead at Mar-a-Lago after breaching the secure perimeter with a shotgun and a fuel can, according to the Secret Service and Palm Beach County sheriff. He drove in through the north gate around 1:30 a.m., slipped in as another vehicle exited, dropped the gas can when ordered — then reportedly raised the shotgun into a firing position, at which point two Secret Service agents and a county deputy opened fire and killed him. Trump was in Washington, not at the resort.
Investigators say the man, believed to be a 21‑year‑old from North Carolina who’d been reported missing by his family days earlier, had apparently traveled south and picked up the weapon on the way; a box for the shotgun was found in his car. The FBI is now canvassing neighbors for security‑camera footage while Palm Beach does its usual split-screen routine: winter tourists with iced coffees on one side, police blocking access roads to the ex‑president’s club on the other.
This is not an isolated incident; it’s the third serious case in 18 months. In July 2024, Thomas Crooks climbed onto a rooftop near a Trump rally in Butler, Pennsylvania, fired eight shots, killed a rallygoer, wounded two others and grazed Trump’s ear before being killed by a Secret Service sniper — after agents had been warned about him as “suspicious” an hour earlier. Two months later, Ryan Routh was caught with a rifle outside Trump’s Florida golf course and is now serving life for attempted assassination.
The Secret Service, already under fire for those failures, now has to argue two things at once: that Trump is protected, and that the system isn’t out of control. On paper, yesterday was a “success” — perimeter breached, threat neutralized, no protectee on site. In any sane democracy, the phrase “another young man with a long gun and a political fixation got within shooting range of the president’s property” would not count as reassurance.
America’s political class will now do what it always does. One camp will turn this into proof Trump is under siege and the state is failing him. The other will quietly enjoy the spectacle of a security apparatus that can’t secure a golf resort. No one will ask why U.S. politics keeps producing lone wolves with rifles, GPS coordinates for Trump’s locations, and just enough competence to reach the outer edge of the Secret Service’s comfort zone.
#Trump#MarALago#SecretService#violence#USA#fakeDemocracy
📱American Оbserver - Stay up to date on all important events
🇺🇸