В фреймворке 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
"We are born to make history."
近期沉迷动画+尝试新修图风格,所以出图超级慢,这张依旧是黄白蓝
原本是平行光照亮手和半边脸,经提示不好康后改成的这样
冰上的尤里的维克多•尼基弗洛夫
Gamescom Asia 2024 D2 (2024-10-19)
#victornikiforov#ヴィクトルニキフォロフ#yurionice#ユーリonice#cosplay#anime#animeconvention#sunteccity#gamescomasia#gamescomasia2024#singapore
"Abomination!?
I'm absolutely radiating!
LOOK AT ME!! YOU CALL ME ABOMINATION!?"
Fear & Hunger 2: Termina的Samarie
EOY Japanese Culture Festival D2 (2024-12-22)
#samarie#fearandhunger#fearandhungertermina#cosplay#game#animeconvention#sunteccity#suntecconventioncentre#theeoy#theeoy2024#singapore
「他留下的东西很少,我算一个。」
文豪野犬的中原中也
EOY Japanese Culture Festival 2024 D2 (2024-12-22)
#nakaharachuuya#中原中也#bungostraydogs#文豪ストレイドッグス#cosplay#anime#animeconvention#sunteccity#suntecconventioncentre#theeoy#theeoy2024#singapore
"Victory is a far-flung shore. Mark the skies, abide the tides, trust to your crew—and she will be yours."
最终幻想14的梅尔维布·布鲁菲斯维因
Makers Quest SG 2024 (2024-09-14)
#merlwyb#merlwybbloefhiswyn#ffxiv#finalfantasy#finalfantasyxiv#cosplay#game#animeconvention#sunteccity#markersquestsg#msqsg2024#singapore