В фреймворке 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
If Donald Trump doesn’t make an attempt to buck the Constitution and run for president once again in 2028, which he has hinted at, his middle son, Eric, has indicated he might like to take his turn in the Oval Office.
#Trump#EricTrump
👂More on Trump's Ear ⚠️
Eric Trump’s Investment Advice Backfires
Eric Trump advised buying Bitcoin and Ethereum, but prices dropped 20% and 30% respectively. World Liberty Financial's portfolio fell by $110 million. His praise messages were deleted after the crash. A false report on ETH purchase circulated, later debunked. For more info, visit ForkLog.
#Bitcoin#Ethereum#Crypto#Investment#MarketCrash#WorldLiberty#FinancialNews#EricTrump#ETH#BTC#Trading#Blockchain#TechNews#Assets#Speculation#Finance#MarketStrategy#News