В фреймворке 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
🌍 Tokyo’s Shinjuku train station is the world’s busiest, with over 3.5 million passengers passing through daily. Its vast underground networks are so complex that some exits are kilometers apart. ✨
#urbanization⚡#infrastructure⚡#transit⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Tokyo’s rail system is so efficient that over 13 billion train trips are made each year within the city. This high-capacity network helps keep the world’s largest metropolitan area moving smoothly. ✨
#Tokyo⚡#transit⚡#urban⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
【TokenPocket Retweeted】
Retweeted TransitFinance : Unlimit Crypto is live🚀! Transit Buy goes global, unlocking infinite crypto possibilities!
🚀#Transit#Buy is now integrated with Unlimit Crypto unlimit_crypto, providing crypto on-ramp support to hundreds of thousands of users globally.
Transit Buy spans the global entry points for #fiat and #cryptocurrency, ensuring #seamless access for you! #Crypto#TransitBuy#UnlimitCrypto
【Details】https://twitter.com/TokenPocket_TP/status/1746088055679934633
【Powered By】Crypto Box