В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
Time to yourself🧘♀️
Indulge in a 45-minute grounding meditation, harmonising your being and cultivating a deep sense of peace and renewal within.
🗓️ Tomorrow, May 14
🕖 7 am - 7.50am
📍Seminyak, at Sunset Park Pool Bar, Level 4, Potato Head Studios
Bookings via the link.
@BaliNews
#wheretogo#Seminyak
🤠Annual Cinco De Mayo party at Motel Mexicola
🪩 Today from 6pm till the late night you can try to win IDR 10 million in Reggaeton Dancing Competition.
🍸 DJs, dancers and good vibes are expected in Seminyak tonight.
@BaliNews
#Seminyak#wheretogo
🤕Two foreigners beat up the Pechalangs at a villa in Seminyak
Kuta police have detained two US citizens, 26-year-old Aabed Attia and his older brother 30-year-old Zeyad Ahmed Attia. According to law enforcers, the Americans beat up two pechalangs (local vigilantes) at a rented villa in Seminyak after being reprimanded over loud music. The foreigners are now in a detention center, awaiting trial.
@BaliNews
#accidents#Kuta#Seminyak
😱 А very impressive python crawled onto Seminyak beach for a rest yesterday
🐍 It was not allowed to rest, though – despite its status as a public beach, the snake was politely but firmly asked to leave.
@BaliNews
#places#incidents#Seminyak
🏚Fire destroys 19 villas in Seminyak
📰 Detikbali reports the the blaze broke out overnight on Kayu Aya Street in the Amasya villa complex. The fight against the fire continued into the morning. The flames were so big that they were seen even from airplanes arriving in Bali.
🎍 Apparently, the reason is that the complex is mostly built in eco-style, a lot of materials such as bamboo and straw were used in the decoration and construction, and they are known to burn well.
💸 Damage from the fire is estimated at 12 billion rupees.
👮♂️ Ketut Sukadi, a spokesman for Denpasar police's public relations department, said:
“The fire first appeared on the second floor of villa 9 of The Amasya Villas complex, then spread to villa 12. A total of 19 villas out of 20 were burned in the fire, only villa 5 was not burned.”
There are no official reports on the cause of the fire or other details yet, authorities are still investigating the incident.
@BaliNews
#accidents#Seminyak#Denpasar