enum Qt::ItemFlag
flags Qt::ItemFlags
This enum describes the properties of an item:
| Constant | Value | Description |
|---|---|---|
| Qt::NoItemFlags | 0 | It does not have any properties set. |
| Qt::ItemIsSelectable | 1 | It can be selected. |
| Qt::ItemIsEditable | 2 | It can be edited. |
| Qt::ItemIsDragEnabled | 4 | It can be dragged. |
| Qt::ItemIsDropEnabled | 8 | It can be used as a drop target. |
| Qt::ItemIsUserCheckable | 16 | It can be checked or unchecked by the user. |
| Qt::ItemIsEnabled | 32 | The user can interact with the item. |
| Qt::ItemIsTristate | 64 | The item is checkable with three separate states. |
Note that checkable items need to be given both a suitable set of flags and an initial state, indicating whether the item is checked or not. This is handled automatically for model/view components, but needs to be explicitly set for instances of QListWidgetItem,QTableWidgetItem, and QTreeWidgetItem.
The ItemFlags type is a typedef for QFlags<ItemFlag>. It stores an OR combination of ItemFlag values.
注意最后一句,ItemFlags存储的是几个ItemFlag的逻辑或的结果。
所以设置某个Item可编辑时,可以item->setFlags(Qt::ItemIsEditable |Qt::ItemIsEnabled);
本文详细介绍了Qt中ItemFlag枚举类型的各个属性及其组合使用方式,包括Item的可选性、可编辑性、拖拽及放置等功能,并强调了如何为列表项设置合适的标志。

959

被折叠的 条评论
为什么被折叠?



