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.7 6.5
Change-Id: I272a20b7e7be13df1ddd9f2ba552dd9da68e2a3b
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 53c6c73c57d36796577a13fd4dd82a04ee9647ab)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2024-09-03 17:46:33 +02:00 committed by Qt Cherry-pick Bot
parent 892012e5d9
commit 5b4842c992
3 changed files with 9 additions and 3 deletions

View File

@ -3285,7 +3285,8 @@ bool QAbstractItemView::isPersistentEditorOpen(const QModelIndex &index) const
to true, otherwise the widget's background will be transparent, showing to true, otherwise the widget's background will be transparent, showing
both the model data and the item at the given \a index. 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 deleted. For example, in the code snippet below, the QLineEdit object will
be deleted. be deleted.

View File

@ -1713,6 +1713,8 @@ QWidget *QListWidget::itemWidget(QListWidgetItem *item) const
implement a custom editor widget, use QListView and subclass QStyledItemDelegate implement a custom editor widget, use QListView and subclass QStyledItemDelegate
instead. instead.
\note The list takes ownership of the \a widget.
\sa itemWidget(), removeItemWidget(), {Delegate Classes} \sa itemWidget(), removeItemWidget(), {Delegate Classes}
*/ */
void QListWidget::setItemWidget(QListWidgetItem *item, QWidget *widget) void QListWidget::setItemWidget(QListWidgetItem *item, QWidget *widget)

View File

@ -2567,6 +2567,8 @@ void QTreeWidgetPrivate::dataChanged(const QModelIndex &topLeft,
\fn void QTreeWidget::removeItemWidget(QTreeWidgetItem *item, int column) \fn void QTreeWidget::removeItemWidget(QTreeWidgetItem *item, int column)
Removes the widget set in the given \a item in the given \a column. Removes the widget set in the given \a item in the given \a column.
\sa itemWidget(), setItemWidget()
*/ */
/*! /*!
@ -3016,6 +3018,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. 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 QWidget *QTreeWidget::itemWidget(QTreeWidgetItem *item, int column) const
{ {
@ -3042,9 +3045,9 @@ QWidget *QTreeWidget::itemWidget(QTreeWidgetItem *item, int column) const
i.e., the QTreeWidgetItem that will hold \a widget must have been added to i.e., the QTreeWidgetItem that will hold \a widget must have been added to
the view before \a widget is set. 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) void QTreeWidget::setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget)
{ {