В фреймворке PyQt (и PySide тоже) часто встречается настройка чего-либо с помощью так называемых флагов.
widget.setWindowFlags(Qt.Window)
Взаимодействие нескольких флагов делается с помощью бинарных (или побитовых) операторов.
Несколько флагов можно указать с помощью оператора "|"
list_item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
исключить флаг из уже имеющегося набора можно так
list_item.setFlags(list_item.flags() ^ Qt.ItemIsEnabled)
Добавить новый флаг к имеющимся можно так
list_item.setFlags(list_item.flags() | Qt.ItemIsEnabled)
А проверка наличия делается так
is_enabled = item.flags() & Qt.ItemIsEnabled > 0
Почему именно так? Всё дело в том как именно работают побитовые операторы. Но об этом в следующем посте.
#qt
🚗✨ Exciting news! The updated Volvo XC90 is set to be unveiled on September 4th! 🌟
🔋 This refreshed model will feature a hybrid powertrain, ensuring it remains relevant until the brand transitions fully to electric vehicles by the end of the decade. ⚡️
Stay tuned for more updates!
#VolvoXC90#HybridPower#SustainableDriving#CarLaunch#Auto
🚗✨ Introducing the updated Volvo XC90! ✨🚗
After nearly a decade, the XC90 has received a stunning makeover with a refreshed exterior featuring new headlights, grille, and bumpers. Plus, enjoy an enhanced suspension and a modern media system with a larger screen! 📱🔊
This new XC90 will only be available with hybrid powertrains based on gasoline engines, as the company has phased out diesel options. ⚡️🚫
🔋 The plug-in hybrid XC90 offers an impressive electric range of about 70 km, with a total driving range of 800 km! Meanwhile, mild-hybrid versions with a 48-volt starter-generator reduce fuel consumption by 15%. 🌍💚
#VolvoXC90#Hybrid#Sustainability#Innovation#CarLovers#NewRelease#Auto
🚗✨The Updated Volvo XC90 Unveiled Ahead of Premiere!🌟
The iconic SUV has undergone a complete makeover, featuring a brand-new front design and an upgraded multimedia system! 🎉🔧
Stay tuned for details on the powertrains, set to be revealed on September 4th during the full premiere! 🗓️👀
#VolvoXC90#CarReveal#SUV#Innovation#Design#Multimedia#Premiere#Auto#VolvoLove