В фреймворке 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
🚨🔫WHCD SHOOTER PLANNED TO TARGET TRUMP OFFICIALS
🔹 Cole Allen, 31, rushed security with shotgun, handgun, and knives at Washington Hilton 🔪
🔹 California teacher wrote "Administration officials are targets" minutes before attack 📝
🔹 Traveled by train from LA to DC, checked into hotel days before correspondents' dinner 🚂
Allen apologized to family but called it his "duty" to target high-ranking officials — except FBI Director Kash Patel 🎯⚖️
Security nightmare: How did he get so close to the President? 😰🛡️
📊 The numbers don't lie. Stay tuned for updates 📱
🌍 This affects more people than you think 📲
#WHCD#Security
@america
🎩🚨MENTALIST RECALLS "ARE WE ABOUT TO DIE?" MOMENT BESIDE TRUMP
🔹 Oz Pearlman was mid-magic trick guessing press secretary's baby name when gunshots erupted at 8:36pm 🍼✨
🔹 Secret Service tackled both performer and president to ground — "his eyes weren't registering," Pearlman says 👁️😰
🔹 Found himself lying half-meter from Trump after meeting him just 5 minutes before the chaos began 📏⏰
🔹 Describes surreal terror of life-threatening moment at what should have been elegant dinner event 🍽️💔
"Split second after my trick reveal, everything went to hell" — witness account chills 😨❄️
This is Hollywood-level crazy but it's real life 🎬😱
#WHCD#performer#witness#security
@america