Sync behavior and documentation of QFoo::setItemDelegate()
QComboBox::setItemDelegate() does delete the old delegate which is in constrast to all other setItemDelegate() functions which is quite confusing. Sync in by *not* deleting the delegate in QComboBox::setItemDelegate() and adjust the documentation to explicitly state that the ownership is *not* passed to the affected classes. [ChangeLog][QtWidgets][QComboBox] QComobBox::setItemDelegates no longer deletes the previous delegate set. Fixes: QTBUG-72483 Change-Id: I89c8e53903e7c9924a980c57b83ce40f5866e6ae Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
b5193881e5
commit
089d54f06f
|
|
@ -2015,6 +2015,9 @@ QStringList QFileDialog::history() const
|
|||
Sets the item delegate used to render items in the views in the
|
||||
file dialog to the given \a delegate.
|
||||
|
||||
Any existing delegate will be removed, but not deleted. QFileDialog
|
||||
does not take ownership of \a delegate.
|
||||
|
||||
\warning You should not share the same instance of a delegate between views.
|
||||
Doing so can cause incorrect or unintuitive editing behavior since each
|
||||
view connected to a given delegate may receive the \l{QAbstractItemDelegate::}{closeEditor()}
|
||||
|
|
|
|||
|
|
@ -383,6 +383,9 @@ QAbstractItemModel *QDataWidgetMapper::model() const
|
|||
data from the model into the widget and from the widget to the model,
|
||||
using QAbstractItemDelegate::setEditorData() and QAbstractItemDelegate::setModelData().
|
||||
|
||||
Any existing delegate will be removed, but not deleted. QDataWidgetMapper
|
||||
does not take ownership of \a delegate.
|
||||
|
||||
The delegate also decides when to apply data and when to change the editor,
|
||||
using QAbstractItemDelegate::commitData() and QAbstractItemDelegate::closeEditor().
|
||||
|
||||
|
|
|
|||
|
|
@ -2096,6 +2096,9 @@ QAbstractItemDelegate *QComboBox::itemDelegate() const
|
|||
Sets the item \a delegate for the popup list view.
|
||||
The combobox takes ownership of the delegate.
|
||||
|
||||
Any existing delegate will be removed, but not deleted. QComboBox
|
||||
does not take ownership of \a delegate.
|
||||
|
||||
\warning You should not share the same instance of a delegate between comboboxes,
|
||||
widget mappers or views. Doing so can cause incorrect or unintuitive editing behavior
|
||||
since each view connected to a given delegate may receive the
|
||||
|
|
@ -2110,7 +2113,6 @@ void QComboBox::setItemDelegate(QAbstractItemDelegate *delegate)
|
|||
qWarning("QComboBox::setItemDelegate: cannot set a 0 delegate");
|
||||
return;
|
||||
}
|
||||
delete view()->itemDelegate();
|
||||
view()->setItemDelegate(delegate);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue