В фреймворке 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
#Pontida24, Matteo #Salvini (#Lega): "Processano una persona che ha fatto il suo dovere, non possono processare un intero popolo. In caso di condanna sono pronto a varcare le porte del carcere a testa alta."
@UltimoraPolitics
#Pontida24, Matteo #Salvini (#Lega) sulle nuove tasse: "Se qualcuno deve pagare qualcosa in più, paghino i banchieri e non gli operai."
@UltimoraPolitics
#Pontida24, Giancarlo #Giorgetti (#Lega): "Non sono un banchiere, sono figlio di un pescatore e di una operaia tessile. So distinguere chi fa i sacrifici e chi li può fare."
@UltimoraPolitics
Europe is in trouble. We worry about the future of our children. The bureaucrats in #Brussels are turning our lives upside down.
They support war instead of #peace.
They support #migration instead of European #families.
And they support economic sanctions instead of economic prosperity.
This has to stop. Patriots for Europe will stop it!
#Pontida24#Patriots#PfE
https://t.me/PM_ViktorOrban