В фреймворке 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
Be a hero, save lives🩸
Participate in the Voluntary #BloodDonation Poster Making Contest on #MyGov and raise awareness about the importance of donating blood.
Visit: https://mygov.in/task/poster-making-contest-voluntary-blood-donation/
#BloodDonation#savelives#donateblood
Be a hero, save lives🩸💉
Participate in the Voluntary #BloodDonation Poster Making Contest on #MyGov and raise awareness about the importance of donating blood.
#BloodDonation#savelives#donateblood
#committosavinglives2023
Visit: https://www.mygov.in/task/poster-making-contest-voluntary-blood-donation/
On Sunday, February 23, 2025, we will be holding a blood donation, dog adoption, and fundraising program in collaboration with Ahadu Rotaract Club at the Red Cross compound around Addis Ababa Stadium starting 9AM
To those who want to donate:
- Food (Rice) for feeding purpose
- Pet beds
- Comfy blankets
- Medications
- Pet toys
- Dry pet foods
- pet accessaries
We will gladly be waiting, the program will be held until 5pm. Come, save lives by donating blood, create a family by adopting dogs!
#BloodDonation#DogAdoption#CommunityService#AddisAbaba#Ethiopia#SaveLives#GiveBack#AnimalRescue#Rotaract#AhaduRotaract#Fundraising#CharityEvent
https://t.me/starvetbooks