В фреймворке 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
🚗✨ Rare Mercedes-Benz S-Class Coupe Up for Auction! ✨🚗
Check out this stunning 1980s Mercedes-Benz 500SEC, expertly tuned by AMG before it became part of the larger automotive group! 🏎️💨
🔧 Specs:
- Original 5.0L V8 upgraded to a powerful 6.0L! 🔥
- Output increased to an impressive 330 HP! 💪
- Features include AMG springs, four-piston brake calipers, and stunning 17-inch OZ Racing wheels. 🛞
- Aerodynamic body kit for that sleek look! 🌬️
Don’t miss your chance to own a piece of automotive history! 🏆
#MercedesBenz#AMG#ClassicCars#CarAuction#SClass#Auto
🚗💨 Introducing the all-new Brabus Mercedes-AMG S-Class! 🌟
This stunning beast boasts a jaw-dropping 1000 horsepower and a mind-blowing 1820 Nm of torque! 🔥💪
🔧 Under the hood, the 4.5-liter V8 has been meticulously upgraded with a custom turbo system, new pistons, and a fresh ECU tune. Get ready for an exhilarating driving experience! 🏎️💨
✨ The exterior features aggressive carbon aerodynamic elements and is finished in a unique shade of grey, perfectly complemented by 22-inch forged wheels. 😍🖤
🛋️ Inside, luxury meets style with exquisite grey quilted leather upholstery that takes comfort to the next level.
#Brabus#MercedesAMG#SClass#LuxuryCars#CarEnthusiast#1000HP#Performance#AutomotiveDesign#CarLovers#Auto🚘✨