В фреймворке 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
⏳ Only 2 Days Left – GuAfrica Giveaway Ends Soon!🇿🇦
We're heading to Africa Tech Week 2025 in Cape Town - and 3 top referrers from Africa will be coming with us! ❄️
This isn’t just a tech conference - it’s where Web3 meets the real world, and where the continent’s brightest builders connect.
🎁 Prize: Entry tickets to Africa Tech Week
📍 Location: Cape Town, South Africa
🗓 Ends: June 1, 2025
🏆How to win: Climb into the Top 3 on the Africa referral leaderboard before time runs out!
This is your moment.
Let’s go, Africa - the future is yours.🎉🔼
#GuGoGlobal#GuAfrica
🌐GuAfrica Giveaway– Win Tickets to Africa Tech Week 2025! ✨
As part of our Gu Go Global journey, we’re heading to Africa — and we want to bring you with us! 📈
We’re giving away exclusive entry tickets to Africa Tech Week 2025, one of the continent’s most impactful tech events. 🥳
🏆 Prize: Entry tickets to Africa Tech Week
📌Location: Cape Town, South Africa
🗓Duration: May 21 – June 1, 2025
👍How to join:Be among the Top 3 on the referral leaderboard in Africa during this period and claim your spot at the event!
From AI and fintech to Web3 and sustainable tech - this is where Africa’s digital future takes shape.
Let’s go, Africa. The future is yours. 👀🛍
#GuGoGlobal#GuAfrica#AfricaTechWeek2025