В фреймворке 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
A car stops in front of the palace at night in a terrifying scene.in the year 2019 in Egypt, above shot, artist by Richard Tuschman Style --ar 16:9 --v 6.1
by mtcreation19
#vehicle
🐝 Prompt collection
#AutoLog#UK#Vehicle#Manager
Join the AutoLog - UK Vehicle Manager beta on ✈️#TestFlight
🔗 Link: https://testflight.apple.com/join/yPmgXjnF
Shared by Dimitri
These Stupid Trucks are Literally Killing Us | Not Just Bikes
One of these vehicles are designed to efficiently carry lots of useful stuff, while the other is designed to carry fragile egos.
———
好強的攻擊性
#Video#Transport#Vehicle#SUV#Urbanist#NJB
https://www.youtube.com/watch?v=jN7mSXMruEo