В фреймворке 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 for Ford Mustang enthusiasts!
🏎️ Roush has just released the Limited Edition Phase 2 kit, boosting the engine by a whopping 330 horsepower for a total of 810 HP! 💥💨
The kit is priced at $9995, offering a significant power upgrade for your Mustang! 🔥
#FordMustang#Roush#LimitedEdition#Auto#PowerUpgrade🌟🚀
🚗💨Manhart’s BMW M3: A Powerhouse!💥
The tuning experts at Manhart have taken the iconic BMW M3 to a whole new level, surpassing the power of the new BMW M5! 🔥
🔧Engine Upgrade: Boosted by a staggering 345 hp, the total output now stands at an incredible 855 hp and 1090 Nm of torque! 💪⚙️
📈Transmission: Enhanced 8-speed automatic for smooth power delivery!
✨Other Upgrades:
• Signature carbon fiber body kit for that aggressive look 🏎️
• Adjustable dampers for a tailored ride experience 🛠️
• Carbon strut brace for increased rigidity 🔩
This specific MH3 800 Touring has already clocked 12,500 km and is up for grabs at €212,000! 💰
#Manhart#BMWM3#PowerUpgrade#CarEnthusiast#LuxuryCars#Tuning#Performance#MH3800Touring#Auto