В фреймворке 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
Nothing OS 2.5 Open Beta 2 | Phone (2) | Android 14
📝 Details:
- Version: 2.5 Beta 2
- Type: #NOS#OBT#A14#Beta
- Codename: #Pong
- Released: 02/11/23
Links:
⬇️ Download : Beta tool | Beta Package (Full) | Incremental (from beta 1) | Rollback (to 2.0.4) | TG Community Archive
⚙️ Changelogs | Official Intro
🏛Nothing Community Website
📸 Screenshots
🗒To-Do List
Disclaimer:
- Keep checking system updates (if you are already on beta 1).
- Since this is a Beta version, there’s a very small chance the test software may interfere with your data and require a factory reset. In this instance, your data will be lost. We strongly recommend backing up all your data before accessing the software.
- Rollback to NOS 2.0.4 Involves data loss, backup prior proceeding
- For those getting error "ENOENT" during Android 14 Beta update:
Make sure you have a folder named Documents in your storage
🔔 Updates : @NothingPhone2Updates
🐙 Chat : @NothingPhone2
Nothing OS 2.5 Open Beta 1 | Phone (2) | Android 14
📝 Details:
- Version: 2.5 Beta 1
- Type: #NOS#OBT#A14#Beta
- Codename: #Pong
- Released: 07/10/23
Links:
⬇️ Download : Beta tool | Beta Package | Rollback | Gdrive
🏛Nothing Community Website (Installation & Changelogs)
📸 Screenshots
🗒To-Do List
Disclaimer:
- Since this is a Beta version, there’s a very small chance the test software may interfere with your data and require a factory reset. In this instance, your data will be lost. We strongly recommend backing up all your data before accessing the software.
- Rollback to NOS 2.0.3 Involves data loss, backup prior proceeding
- For those getting error "ENOENT" during Android 14 Beta update:
Make sure you have a folder named Documents in your storage
🔔 Updates : @NothingPhone2Updates
🐙 Chat : @NothingPhone2