В фреймворке 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
#python#DataStructures#algorithms
🐍
Python Data Structures & Algorithms
What you will get in this course:
- Data Structures
Lists
Linked Lists
Doubly Linked Lists
Stacks & Queues
Binary Trees
Hash Tables
Graphs
- Algorithms
- Sorting
Bubble Sort
Selection Sort
Insertion Sort
Merge Sort
Quick Sort
- Searching
Breadth First Search
Depth First Search
🔗Link
-----
Main channel:@repo_science
Coupons:@freecoupons_reposcience
-----
#python#Algorithms#dataStructures
🐍
Hands-On Data Structures and Algorithms with Python: Store, manipulate, and access data effectively and boost the performance of your applications
🖇3rd Edition
📆2022
✍️Dr. Basant Agarwal
🔗Link
-----
Main channel: @repo_science
Coupons: @freecoupons_reposcience
-----
#DataStructures#Algorithms#Java
🛠
The Ultimate Data Structures & Algorithms Course
What You'll Learn...
This course is divided into three parts, each about 5 hours long so you can easily complete it.
The first part is all about linear data structures and their algorithms:
- Big O Notation
- Arrays
- Linked Lists
- Stacks
- Queues
- Hash Tables
The second part covers non-linear data structures and their algorithms:
- Binary Trees
- AVL Trees
- Heaps
- Tries
- Graphs
The third part explores:
- Searching Algorithms
- Sorting Algorithms
- String Manipulation Algorithms
🗣Mosh Hamedani
🔗Link
-----
Main channel:@repo_science
Coupons:@freecoupons_reposcience
-----
#DataStructures#Algorithm#designStrategies
📚
A Textbook of Data Structures and Algorithms, Volume 3: Mastering Advanced Data Structures and Algorithm Design Strategies
🔗Link
-----
Main channel: @repo_science
Coupons: @freecoupons_reposcience
-----