В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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
#WellnessWednesday: Stay Active. Stay Healthy! 💪🏾
Staying active doesn’t always require a gym membership, sometimes it’s the little things that make the biggest impact!
🚶🏾♀️➡️ Take the stairs instead of the elevator walking
🙆🏾♀️ Stretch during work breaks
🗣️ Engage in quick walks or light conversations with colleagues
🧍🏾♀️Stay on your feet while prepping meals or organizing your space
These simple movements can help reduce stress, improve mood, boost focus, and support your overall health. Whether you’re at home or at work, every step counts!
#Wellnesswednesday#NCDCNigeria#HealthyHabits
#FactFriday: Good Food, Good You!
🥬🥦Adding more fruits and vegetables to your meals can be a game changer for your health. They are filled with Vitamins, Minerals and fiber that helps boost your immunity, Protect your heart and lower the risk of chronic diseases.
Healthy eating starts with fruits and Vegetables✅️
#FactFriday#HealthyLiving#HealthyHabits#NCDCNigeria.
#Healthtiip Monday: Clean hands, Healthy You!
💦Regular handwashing with soap under running water or using an alcohol-based sanitizer is one of the most effective ways to protect against infectious diseases, including Ebola.
In times of outbreaks, this simple habit can make a big difference.
✅ Every wash helps to break the chain of transmission and keep you, your loved ones, and your community safe.
#HealthTipMonday#HealthyLiving#HealthyHabits#NCDCNigeria