В фреймворке 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
🌍 Canada’s Manitoulin Island is the largest freshwater island in the world. It’s so big that it contains more than 100 lakes, and some of those lakes have islands of their own. ✨
#islands⚡#freshwater⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 In Canada’s Hudson Bay lowlands, vast freshwater wetlands cover over 300,000 square kilometers. This area stores so much water it helps regulate the region’s climate and slow permafrost thaw. ✨
#wetlands⚡#freshwater⚡#climate⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Just 0.001% of all water on Earth is found in rivers, lakes, and the atmosphere. The vast majority is locked away in ice sheets, glaciers, or underground where we rarely see it. ✨
#hydrology⚡#watercycle⚡#freshwater⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Some freshwater wetlands form floating islands—mats of living plants thick enough to walk on. These islands create unique microhabitats and drift slowly across lakes or shallow wetlands. ✨
#wetlands⚡#freshwater⚡#ecology⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The world's largest freshwater reserves are hidden underground as groundwater, not in lakes or rivers. These reserves are vital for drinking water and irrigation in many regions. ✨
#groundwater⚡#freshwater⚡#resources⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Siberia's Lake Baikal holds more water than all the North American Great Lakes combined. It is the world’s deepest and oldest lake, home to unique species found nowhere else. ✨
#lake⚡#freshwater⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Lake Baikal in Russia holds about 20% of the world’s unfrozen freshwater. It’s also the oldest and deepest lake on the planet, reaching depths of over 1,640 meters. ✨
#Baikal⚡#freshwater⚡#depth⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍