В фреймворке 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
🔋🇺🇸EV REVOLUTION IN REVERSE — NEW ELECTRIC CAR SALES CRASH 27% AS TAX CREDITS VANISH
🔹 Q1 sales plummet to just 216k units as post-credit shock decimates demand — market share nosedives from 10.5% to 4.8% 📉
🔹 Ford EV deliveries obliterated by 70% while Honda collapses 81% — automakers bleeding red ink on every unit sold 🏭
🔹 Used electric cars hit record 43k monthly sales as buyers refuse to pay full sticker on brand new models 🚗
🔹 Nissan cancels US factory plans entirely while battery makers scramble for shrinking order books worldwide 🔧
Americans love the idea of EVs — they just refuse to pay premium prices without Uncle Sam's help 💀🔥
#EVCrisis#AutoNews
@america
🚗✨Lexus Unveils Upgraded LC Coupe and Convertible!✨🚗
Since its debut in 2017, the Lexus LC family has received a sleek exterior makeover and new interior materials. But that's not all! The updated models now feature a stiffer chassis, thanks to additional braces installed under the floor near the front and rear axles, enhancing overall handling. 🏎️💨
Under the hood, the Lexus LC offers a powerful lineup: a 5.0L V8 engine producing 477 hp or a hybrid V6 powertrain with a 3.5L engine delivering 359 hp. 🔥🔋
#LexusLC#LuxuryCars#CarEnthusiast#DrivingExperience#AutoNews#V8Power#Auto
🚙✨ Exciting News! The new Mitsubishi Pajero Sport has hit the testing grounds! 🛤️🔍
Despite its camouflage, it's clear that the front design draws inspiration from the current L200/Triton pickup. 🛻💨 The new front end beautifully complements the familiar rear styling.
Could this be a prototype testing individual components in a non-production body? 🤔🔧
While the release date remains a mystery, the current model is set to be discontinued in 2025. ⏳📅
#MitsubishiPajeroSport#CarTesting#NewRelease#Mitsubishi#SUV#AutoNews#Innovation#Auto