В фреймворке 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
🚨 BREAKING: $117M in assets stolen from @Balancer in the last 2 hours after a major hack!!!
🔹 Assets stolen are across multiple chains: #Ethereum, #Base, #Optimism, #Sonic, #Polygon, #Berachain – mainly in Liquid Staking Tokens (LSTs) of $ETH.
Top 5 stolen assets:
• 7,838 $WETH (~$29.1M)
• 6,841 $OSETH (~$26.8M)
• 4,459 $WSTETH (~$20.1M)
• 2,405 $SFRXETH (~$10M)
• 2,038 $RSETH (~$8.67M)
🔹 The hacker is acting quickly: Converting LSTs into $ETH in real-time!
🔹 Big move: Whale account 0x009, dormant for 3 YEARS, just resurfaced after the exploit and withdrew $7.38M worth of assets from #Balancer!
⚠️ ALERT: If you’re still on #Balancer, secure your funds NOW before it’s too late! 🔐
Follow @spotonchain for more updates about the hack!
https://x.com/spotonchain/status/1985289043383300351