В фреймворке 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
🎬 Nine films. Nine stories celebrating the charm and character of Singapore’s conserved buildings.
✨ Discover how these spaces, beautifully restored, continue to serve our needs today.
📺 Watch the films and cast your vote for the People’s Choice Award by liking your favourite in the NTU-AHA Films playlist. Voting ends on 12 Dec 2025, 6pm: https://go.gov.sg/ahashortfilms
#SingaporeArchitecture#SGHeritage#BuiltHeritage
👀 Look up the next time you walk past a shophouse!
Shophouse signages are more than just names on a building, they add character to our streetscapes.
Swipe through to to see how good signage design practices help to keep the charm of our conservation areas alive! 👉
#URAMemos#ConservationSG#SGHeritage#ShophousesOfSG
Love the vibes at Holland Village? We do too 🙌
From low-rise buildings to continuous walkways and elegant signages, find out how we’re retaining the unique charm and familiar identity of the area through thoughtful planning and design.
#HollandVillage#ExploreSingapore#UrbanDesign#IdentityNode#SGHeritage