В фреймворке 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
#BREAKINGNEWS
🔴 US President Biden confessed
- Were these bombs that were stopped from being shipped to Israel used to kill civilians in Gaza?
+ They were previously used to kill civilians in Gaza and destroy population centers.
🚨
🚨
🚨#BREAKINGNEWS
The occupying Israeli army has launched a very violent attack on the east of Rafah as of now.
The attacked areas are the area that Israel demanded to be evacuated in the morning.
🚨#BREAKINGNEWS
The Kassam Brigades broadcast the moments of shelling the Israeli occupation forces with heavy caliber mortars in Netsarim, south of Gaza City.
🚨#BREAKINGNEWS
A Turkish youth staged a stabbing operation in Israeli-occupied Jerusalem, wounding an Israeli policeman. The youth was martyred. (Haaretz)