В фреймворке 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
The Toronto HongKonger Dragon Boat team is now recruiting.
About the team:
We stand with HongKongers. Our goal is to regain HongKongers’ energy in Toronto and maintain our Lion Rock spirits high and strong in Canada through dragon boat racing, spreading the name of 'HongKongers' to more people.
coach – Matthew Ma:
👉🏻10 years of experience
👉🏻8 years as a certified dragon boat coach.
👉🏻was a part of the national team that represented Canada in the 13th and 14th World Dragon Boat Racing Championships in China and Thailand.
Facebook: https://www.facebook.com/profile.php?id=61554437804498&mibextid=LQQJ4d
Instagram: https://www.instagram.com/tohkdbt?igsh=MXF1NXRhMWdxYjEwcQ==
Email: [email protected]
Application: form at https://forms.gle/7HS5Uao5xFQd9isUA
#hongkonger#toronto#torontohongkonger
#drangonboatteam
#dragonboatrecruitment