В фреймворке 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
Stress changes meaning — but you have to hear it to notice it 👂
Some English words look the same as nouns and verbs,
but the stress moves — and it sounds very different.
Watch these short videos to actually hear it:
📹https://youtu.be/Hh1PlngNt2Q?t=64
📹https://www.youtube.com/watch?v=7q8yk896pnc
Listening is the only way you’ll spot the difference.
Try saying these aloud after you watch 🎤
#EnglishLearning#Pronunciation#RealEnglish
Vocabulary tips are everywhere — but which one actually works?
You’ve probably seen all of these tips before.
The real question is:
Which one do you actually use?
#EnglishLearning#Vocabulary#LearnEnglish#EnglishTips#RealEnglish
5 phrasal verbs with “PAY”
I shared the questions first on purpose — to make you think before seeing the meanings.
That struggle helps the meanings stick better than passive reading.
If a meaning surprised you, that’s good — it means your brain is actually learning.
#EnglishLearning#PhrasalVerbs#LearnEnglish#RealEnglish