В фреймворке 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
👀 Celia LaunchPad is on the way.
Imagine launching your own tradable coin in a single click…no dev skills, no complicated setup. Just you and your idea, ready for the world. 🚀
#CeliaWallet#CeliaLaunchPad#Web3#Crypto
🇳🇬 Nigerians, the wait is over!
Pay your Airtime, Data, Electricity & Cable TV bills directly with crypto on Celia Wallet — no bank, no stress, just crypto. 🔥
We're starting with Nigeria and rolling out GLOBALLY very soon. 🌍
📲 Download Celia Wallet & start paying your bills with crypto today!
$CELIA | #CeliaWallet#CeliaUtilities#CryptoNigeria
Who said crypto can't be fun? 👀🎮
Play games on Celia Wallet. Climb the leaderboard. Earn real rewards in $CELIA & $USDT every single week.
🏆 Top 10 players get PAID weekly, no cap.
And guess what? More games are dropping soon 👀🔥
We're not just a wallet. We're making crypto fun while you trade 💸
Your move 👇 Download Celia and start playing.
https://onelink.to/g6bbq8
#CeliaWallet#PlayToEarn#CryptoGaming#Web3#USDT#CELIA