В фреймворке 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
G20's #DigitalInnovationAlliance is promoting #Startups with digital solutions from across the world!
Want to contribute in this global journey?
Design a logo for G20-DIA
Visit: https://www.mygov.in/task/logo-design-competition-g20-dia/
"G20-DIA bringing Hon'ble PM Narendra Modi's dream to life"
Be part of G20 #DigitalInnovationAlliance.
Know more & Apply at: meitystartuphub.in/g20-dia/
#G20India#G20DEWG
Are you interested in creating digital innovations for the upliftment of societies?
Participate in G20 #DigitalInnovationAlliance
Visit: https://mygov.in/task/launch-applications-g20-digital-innovation-alliance/
#G20DIA#G20India
Calling startups in the field of #agritech & other sectors, developing digital solutions that can reduce the digital divide and boost the global economy for G20 #DigitalInnovationAlliance.
Know more at https://mygov.in/task/launch-applications-g20-digital-innovation-alliance/
#G20India