diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/global/qnamespace.h | 3 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 7 | ||||
-rw-r--r-- | src/widgets/itemviews/qitemdelegate.cpp | 2 | ||||
-rw-r--r-- | src/widgets/itemviews/qstyleditemdelegate.cpp | 2 |
4 files changed, 10 insertions, 4 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index fccb0d5421..4a3c9c546e 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1475,7 +1475,8 @@ public: ItemIsUserCheckable = 16, ItemIsEnabled = 32, ItemIsTristate = 64, - ItemNeverHasChildren = 128 + ItemNeverHasChildren = 128, + ItemIsUserTristate = 256 }; Q_DECLARE_FLAGS(ItemFlags, ItemFlag) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index c8aa53aced..e49bc1565f 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2574,8 +2574,13 @@ \value ItemIsDropEnabled It can be used as a drop target. \value ItemIsUserCheckable It can be checked or unchecked by the user. \value ItemIsEnabled The user can interact with the item. - \value ItemIsTristate The item is checkable with three separate states. + \value ItemIsTristate The item can show three separate states. + This enables automatic management of the state of parent items in QTreeWidget + (checked if all children are checked, unchecked if all children are unchecked, + or partially checked if only some children are checked). \value ItemNeverHasChildren The item never has child items. + \value ItemIsUserTristate The user can cycle through three separate states. + This value has been added in Qt 5.5. 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. diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp index 9303800e87..701eb52b62 100644 --- a/src/widgets/itemviews/qitemdelegate.cpp +++ b/src/widgets/itemviews/qitemdelegate.cpp @@ -1182,7 +1182,7 @@ bool QItemDelegate::editorEvent(QEvent *event, } Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt()); - if (flags & Qt::ItemIsTristate) + if (flags & Qt::ItemIsUserTristate) state = ((Qt::CheckState)((state + 1) % 3)); else state = (state == Qt::Checked) ? Qt::Unchecked : Qt::Checked; diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp index 9d16b2abfc..c1de608a6e 100644 --- a/src/widgets/itemviews/qstyleditemdelegate.cpp +++ b/src/widgets/itemviews/qstyleditemdelegate.cpp @@ -660,7 +660,7 @@ bool QStyledItemDelegate::editorEvent(QEvent *event, } Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt()); - if (flags & Qt::ItemIsTristate) + if (flags & Qt::ItemIsUserTristate) state = ((Qt::CheckState)((state + 1) % 3)); else state = (state == Qt::Checked) ? Qt::Unchecked : Qt::Checked; |