В фреймворке 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
🌍 More than 40% of the world's population is under age 25—a record share of young people. This youth wave is largest in Africa and South Asia, shaping future trends worldwide. ✨
#demography⚡#youth⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Since the 1990s, the number of people living outside their birthplace has more than doubled, with most international migration now happening between countries in Asia and Europe. ✨
#migration⚡#demography⚡#movement⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Some rural areas in Eastern Europe are experiencing net population loss as younger generations migrate westward, leaving behind villages with only a handful of elderly residents. ✨
#migration⚡#demography⚡#Europe⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Just 2% of the world’s population lives in countries with fewer than one million people, while over half reside in just seven nations, highlighting an immense population imbalance. ✨
#population⚡#demography⚡#distribution⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels