В фреймворке 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
There’s a bird that smells like manure. The hoatzin, a bird found in the Amazon rainforest, has earned the nickname “the stinkbird.” Its digestive system ferments leaves the way cows digest grass, producing a strong manure-like smell. Because of this, predators often avoid it—not because it’s dangerous, but because it smells terrible.
@googlefactss#birds
[read more....]
The Argentine lake duck (Oxyura vittata) holds the record for the longest penis of any vertebrate relative to its body size. Males possess a corkscrew-shaped, spiny, and often-retracted organ that can measure up to 20 cm (nearly 8 inches).
@googlefactss#birds