В фреймворке 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
🌎 Golden poison dart frogs from Colombia are among the world’s most dangerous animals. Their skin holds enough potent toxin to kill up to 10 adults. The toxin, called batrachotoxin, blocks nerve signals to muscles, causing paralysis and death even in small doses. ✨
#animals⚡#toxins⚡#Colombia
👉subscribe Interesting Planet
👉more Channels
🌎 The rainbow mantella frog of Madagascar sports neon green and orange skin, warning predators of its toxicity. These tiny amphibians gain their deadly defenses from eating certain ants and mites in the wild. ✨
#amphibians⚡#Madagascar⚡#toxins
👉subscribe Interesting Planet
That "new car smell" is a toxic chemical cocktail! ☠️
You're breathing VOCs from plastics, foam, and adhesives—including formaldehyde. It's essentially off-gassing from your car's interior.
Carmakers are now phasing it out for health reasons.
[Read more]
@googlefactss#NewCarSmell#Toxins#HealthWarning#CarFacts