В фреймворке 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
🚗💨Exciting news from Tata!
🌟 They have unveiled the first Indian crossover coupe - Curvv!
🇮🇳 Set to hit the market on August 7th, this car will be available with petrol, diesel, and fully electric engines.
🌿 Stay tuned for more details on this innovative vehicle! 🤩👏
#TataCurvv#Innovation#Auto#ElectricFuture🌏🔌
🚗✨ Introducing the Alpenglow Hy6 by Alpine! 🌟
This stunning concept car is the evolution of the Alpenglow Hy4, showcasing a powerful V6 engine that delivers an impressive 730 hp and 770 Nm of torque—all powered by hydrogen! 💨🔋
Built on a lightweight carbon LMP3 chassis, the Hy6 promises thrilling performance and cutting-edge technology. Production is on the horizon, with the possibility of an all-electric powertrain on the assembly line! ⚡️🌍
#Alpine#AlpenglowHy6#HydrogenPower#ElectricFuture#CarEnthusiast#ConceptCar#Innovation#Auto🚀