В фреймворке 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
🌳 Hidden Forest & Monkey Kingdom near Durban 🐵
Explore the Hidden Forest Sanctuary in Ballito, where primates roam free in a lush natural haven! Just 40 km (25 mi) north of Durban in KwaZulu-Natal, this gem opened in 2019 and is a must-visit for wildlife lovers.
📍 Ballito, South Africa
🎥 Video: https://www.youtube.com/watch?v=Nfo7xp5YtBE&list=PL6fK0Yu-8iyQTFxtSn5GlKM65_ACMniU3&index=1
#Nature#Monkeys#Travel#SouthAfrica
🌎 In the lush forests of Borneo, the proboscis monkey sports a huge, pendulous nose. This unique feature helps males amplify their calls and attract mates, making it one of nature’s most unusual adaptations for communication. ✨
#borneo⚡#monkeys⚡#evolution
👉subscribe Interesting Planet