QTreeWidgetItem 点击可编辑修改

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. It stores an OR combination of ItemFlag values.

 

注意最后一句,ItemFlags存储的是几个ItemFlag的逻辑或的结果。

所以设置某个Item可编辑时,可以item->setFlags(Qt::ItemIsEditable |Qt::ItemIsEnabled);

 

你可能感兴趣的:(QT)