В фреймворке 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
🌍 Milan has over 3 million trees as part of its city plan, giving it more trees than people. Urban forests like this reduce heat, clean air, and boost well-being for city residents. ✨
#cities⚡#sustainability⚡#planning⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Hong Kong’s extensive network of elevated walkways—some stretching over 800 meters—lets people travel between major buildings without ever touching the street, maximizing space in the crowded city. ✨
#urban⚡#planning⚡#cityscape⚡#infrastructure⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
#python#agent_computer_interface#ai_agents#computer_automation#computer_use#grounding#gui_agents#in_context_reinforcement_learning#memory#mllm#planning#retrieval_augmented_generation
Agent S2 is a smart AI assistant that handles computer tasks by breaking them into smaller steps and using specialized tools for each part, making it highly adaptable and efficient across different systems like Windows and Android. It outperforms other AI tools in completing complex tasks, learns from experience, and adjusts plans as needed, helping users automate digital work more reliably and effectively.
https://github.com/simular-ai/Agent-S