В фреймворке 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
🌎 On Neptune’s largest moon Triton, geysers of nitrogen ice erupt from beneath the surface, shooting plumes up to 8 kilometers high into the tenuous atmosphere. These cryovolcanic eruptions are driven by sunlight warming a thin layer of transparent ice, a unique phenomenon that shapes Triton's mysterious, dark-streaked terrain. ✨
#Triton⚡#cryovolcanism⚡#Neptune
👉subscribe Universe Mysteries
🪐 On Triton, Neptune's largest moon, icy volcanoes known as cryovolcanoes have been observed erupting plumes of nitrogen gas many kilometers high. This frigid world’s surface is scattered with dark streaks—evidence of these geysers venting from below, hinting at surprising geologic activity beneath its frozen crust. ✨
#Triton⚡#cryovolcanoes⚡#Neptune
👉subscribe Universe Mysteries
🪐 On Neptune’s moon Triton, geysers erupt through its icy crust, blasting nitrogen gas more than 8 kilometers above the surface. These plumes create dark streaks and ever-changing patterns on Triton's frozen landscape, transforming the distant moon into one of the most dynamic worlds in the outer solar system. ✨
#Triton⚡#geysers⚡#Neptune
👉subscribe Universe Mysteries
🪐 Within our solar system, scientists have discovered that the subsurface ocean of Neptune’s moon, Triton, could provide the right conditions for life despite its bitterly cold surface. Tidal forces, or gravitational stretching from Neptune, may keep this hidden ocean liquid beneath Triton’s icy shell, making it a fascinating target in the ongoing search for places where life could exist beyond Earth. ✨
#Triton⚡#ocean⚡#astrobiology⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 Neptune’s largest moon, Triton, is thought to conceal a hidden ocean beneath its frozen exterior, thanks to heat generated by radioactive decay in its rocky core. Despite surface temperatures near minus 235°C, this internal heat may keep water liquid deep inside, making Triton one of the most intriguing ocean worlds in the outer solar system. ✨
#Triton⚡#oceanwonder⚡#Neptune⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels