diff options
author | Christian Ehrlicher <[email protected]> | 2024-09-03 17:46:33 +0200 |
---|---|---|
committer | Christian Ehrlicher <[email protected]> | 2024-09-03 21:27:34 +0200 |
commit | 53c6c73c57d36796577a13fd4dd82a04ee9647ab (patch) | |
tree | dcdf4383a1c0f8587c4ef7ba502d6fdfa27b5ef1 | |
parent | 14481614439a2fcb1f7f3d7820334f5af50be732 (diff) |
Itemviews/doc: add not about ownership for setItemWidget()
QListWidget/QTreeWidget::setItemWidget() take ownership of the widget.
This was documented for QTreeWidget but not for QListWidget. Unify the
wording with QAbstractItemView::setIndexWidget() (which gets called by
setItemWidget()).
Pick-to: 6.8 6.7 6.5
Change-Id: I272a20b7e7be13df1ddd9f2ba552dd9da68e2a3b
Reviewed-by: David Faure <[email protected]>
Reviewed-by: Axel Spoerl <[email protected]>
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 3 | ||||
-rw-r--r-- | src/widgets/itemviews/qlistwidget.cpp | 2 | ||||
-rw-r--r-- | src/widgets/itemviews/qtreewidget.cpp | 7 |
3 files changed, 9 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 5f3596e97cf..0d8236828fa 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -3302,7 +3302,8 @@ bool QAbstractItemView::isPersistentEditorOpen(const QModelIndex &index) const to true, otherwise the widget's background will be transparent, showing both the model data and the item at the given \a index. - If index widget A is replaced with index widget B, index widget A will be + \note The view takes ownership of the \a widget. + This means if index widget A is replaced with index widget B, index widget A will be deleted. For example, in the code snippet below, the QLineEdit object will be deleted. diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 674028df2bb..66d73befe6f 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -1691,6 +1691,8 @@ QWidget *QListWidget::itemWidget(QListWidgetItem *item) const implement a custom editor widget, use QListView and subclass QStyledItemDelegate instead. + \note The list takes ownership of the \a widget. + \sa itemWidget(), removeItemWidget(), {Delegate Classes} */ void QListWidget::setItemWidget(QListWidgetItem *item, QWidget *widget) diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index a6f6c9f9366..dbc3fb692cf 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -2539,6 +2539,8 @@ void QTreeWidgetPrivate::dataChanged(const QModelIndex &topLeft, \fn void QTreeWidget::removeItemWidget(QTreeWidgetItem *item, int column) Removes the widget set in the given \a item in the given \a column. + + \sa itemWidget(), setItemWidget() */ /*! @@ -2974,6 +2976,7 @@ bool QTreeWidget::isPersistentEditorOpen(QTreeWidgetItem *item, int column) cons /*! Returns the widget displayed in the cell specified by \a item and the given \a column. + \sa setItemWidget(), removeItemWidget() */ QWidget *QTreeWidget::itemWidget(QTreeWidgetItem *item, int column) const { @@ -2998,9 +3001,9 @@ QWidget *QTreeWidget::itemWidget(QTreeWidgetItem *item, int column) const i.e., the QTreeWidgetItem that will hold \a widget must have been added to the view before \a widget is set. - \note The tree takes ownership of the widget. + \note The tree takes ownership of \a widget. - \sa {Delegate Classes} + \sa itemWidget(), removeItemWidget(), {Delegate Classes} */ void QTreeWidget::setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget) { |