В фреймворке 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
Matter exists in different states:
● Solid – fixed shape and volume, particles tightly packed.
● Liquid – fixed volume, no fixed shape, particles slide past each other.
● Gas – no fixed shape or volume, particles far apart.
● Plasma – like gas but particles are charged.
● Glass – between solid and liquid, amorphous.
● Superfluid – liquid with no resistance near absolute zero.
● Bose-Einstein Condensate – particles act as one quantum entity.
● Fermionic Condensate – similar to Bose-Einstein but formed by fermions.
● Dropleton – quantum liquid of electrons and holes.
● Degenerate Matter – exists under extreme pressure inside stars or planets.
Matter changes state when energy is added or removed.
[Source]
https://t.me/googlefactss
@googlefactss🔬🌡️#Science#Matter#Physics#Education