В фреймворке 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
⚠️ A whale who supplied 56,995 $WETH ($90.8M) to borrow $DAI on #Maker is on the verge of liquidation, with a liquidation price of $1,564.58.
Earlier today, another giant whale was already liquidated for 67,569 $ETH ($106M) at $1,650 to repay a $74.49M loan as the price plunged!
In the past 24 hours, $898M, mostly from long positions, was liquidated from the cryptocurrency market.
Follow @spotonchain for more insights at https://x.com/spotonchain/status/1909075294834848057