В фреймворке 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
🌍 Since the 1960s, Dubai’s desert coast has transformed into a global business hub through free trade zones, drawing global companies and turning once barren sands into a vibrant economic powerhouse. ✨
#economicgeography⚡#trade⚡#urbanization⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Chicago area is the world’s largest concentration of inland rail and freight connections, making it a vital hub where goods from coasts and the Midwest converge before heading nationwide. ✨
#economicgeography⚡#transport⚡#trade⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 More than half of global economic activity now takes place within just 1% of the world’s land surface, showing how powerful major cities and industrial regions are for global wealth. ✨
#economicgeography⚡#cities⚡#industry⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Japan’s Tokaido corridor between Tokyo and Osaka packs over 60 million people and is a global hub for high-speed trains, industry, and services, shaping a megaregion central to Asia’s economy. ✨
#economicgeography⚡#megaregion⚡#infrastructure⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels