В фреймворке 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
🪐 Astronomers using the OGLE survey have discovered a population of rogue planets, including a free-floating world called OGLE-2012-BLG-1323, which might be smaller than Earth and drifts alone through the Milky Way. Rogue planets like this have no parent star, traveling in permanent darkness—detected only by the way they briefly bend and magnify light from distant stars, a phenomenon known as gravitational microlensing. ✨
#rogueplanets⚡#exoplanets⚡#microlensing⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 One of the most massive rogue planets discovered so far is OGLE-2016-BLG-1190Lb, found through a process called gravitational microlensing—when a planet’s gravity briefly magnifies the light from a distant star as it passes in front. This giant, roughly 13 times the mass of Jupiter, drifts through space far from any star, showing that even enormous planets can roam the galaxy alone, undetectable except when they create these rare cosmic magnifying events. ✨
#rogueplanets⚡#microlensing⚡#giants⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels