В фреймворке 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
⚡️ Game Adjustment Alert ⚡️
Starting from floor 2, rooms without NFT will see a 50% decrease in earnings! 👀
Application time: From 13:00 UTC - Oct 9
You know what to do! Don’t let those NFTs sit idle in the Vault—equip them NOW for max earnings 💥🎤
#SingSingTycoon#NFTPower
🎤Announcement | Chat | X (Twitter) | Website | Game
🎤 Ready to take your karaoke empire to the next level? With Karaoke Box NFT and KTV NFT, the path to becoming the ultimate tycoon is within reach!
💥 Karaoke Box NFT is your ticket to faster earnings! The rarer the box, the more your earning speed skyrockets:
Common ➡️ x1.5 earning speed
Uncommon ➡️ x2 earning speed
Rare ➡️ x4 earning speed
Epic ➡️ x6 earning speed
Legendary ➡️ x8 earning speed
🏢 Meanwhile, the KTV NFT is key to unlocking more floors, allowing your karaoke chain to expand beyond limits:
Common ➡️ +1 floor
Uncommon ➡️ +3 floors
Rare ➡️ +5 floors
Epic ➡️ +10 floors
Legendary ➡️ +15 floors
✨ The rarer the NFT, the bigger the rewards! Time to upgrade and watch your karaoke business thrive like never before! 🚀
Check out how to leverage your NFTs here: https://t.me/singsingchannel/831
#SingSingTycoon#NFTPower
🎤Announcement | Chat | X (Twitter) | Website | Game