В прошлом посте говоря "Все вызовы теперь одинаковы" я несколько слукавил. Всё-таки есть в этом зоопарке версий некоторая несовместимость вызов которой просто так не унифицировать. Эти моменты вынесены в отдельный модуль 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: The Power of Hydration
Water is more than just a thirst quencher, it's essential for energy, brain function, digestion, toxin removal, and overall physical performance.
✔️Make hydration a daily priority for a healthier, stronger you.
#WellnessWednesday#StayHydrated#HealthyLiving#NCDCNigeria#PublicHealth
🌱 Today's Health Tip: The Power of Hydration
Staying hydrated is crucial for maintaining good health. Water helps regulate body temperature, aids digestion, and keeps your skin healthy.
💧 Aim to drink at least 8 glasses of water a day, more if you're active or in hot weather.
🥤 Remember, staying hydrated doesn't just mean water. You can also get fluids from fruits, vegetables, and herbal teas.
🍉🥒 Incorporating water-rich foods like watermelon and cucumber into your diet can also help keep you hydrated throughout the day.
Stay hydrated, stay healthy! 💦#HealthTips#StayHydrated#WellnessWednesday
🗂Source : @HeathSafetyTps
♻️SHARE NOW
#HealthTipMonday – Stay Hydrated, Especially in This Hot Weather!
The heat right now is INTENSE 🥵
💧 Dehydration can sneak up on you, causing headaches, fatigue, dizziness, and even heat exhaustion. Staying hydrated is key to staying healthy in this heat!
✅ Drink at least 8 glasses of water daily : You lose more fluids when it’s hot, so drink up!
✅ Avoid sugary drinks : They can worsen dehydration. Stick to water, coconut water, or natural fruit juices.
✅ Carry a reusable water bottle : Always have water handy, whether at work, home, or on the go.
✅ Eat water-rich foods : Snack on watermelon, cucumbers, oranges, and pineapples to boost hydration.
✅ Watch for dehydration signs : Dry mouth, dark urine, and dizziness mean you need more water!
🚰 Don’t wait till you’re thirsty, drink water regularly! Stay cool, stay hydrated, and stay safe in this heat.
#HealthTipMonday#StayHydrated#BeatTheHeat#NCDCNigeria