В фреймворке 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
🌍 The city of Venice, built on more than 100 small islands, uses a vast network of canals instead of streets. Its unique layout has helped it survive for centuries on shifting lagoon mud. ✨
#city⚡#canals⚡#adaptation⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌎 Amsterdam’s famous canal system was shaped by centuries of human engineering. Over 100 kilometers of canals were dug since the 17th century to manage water, transportation, and city expansion. Today, the city relies on more than 1,500 bridges to connect its neighborhoods. ✨
#Amsterdam⚡#canals⚡#engineering
👉subscribe Interesting Planet
👉more Channels
🌎 Amsterdam’s famous canal system shaped the city’s landscape but also lowered the local water table. Over 1,500 wooden bridge and building foundations are now monitored for rotting due to changing groundwater levels. ✨
#Amsterdam⚡#canals⚡#urbanization⚡#groundwater
👉subscribe Interesting Planet
👉more Channels