Inheritance diagram of PySide2.QtWidgets.QItemEditorFactory



Virtual functions

Static functions

Detailed Description

The PySide2.QtWidgets.QItemEditorFactory class provides widgets for editing item data in views and delegates.

When editing data in an item view, editors are created and displayed by a delegate. PySide2.QtWidgets.QItemDelegate , which is the delegate by default installed on Qt’s item views, uses a PySide2.QtWidgets.QItemEditorFactory to create editors for it. A default unique instance provided by PySide2.QtWidgets.QItemEditorFactory is used by all item delegates. If you set a new default factory with PySide2.QtWidgets.QItemEditorFactory.setDefaultFactory() , the new factory will be used by existing and new delegates.

A factory keeps a collection of PySide2.QtWidgets.QItemEditorCreatorBase instances, which are specialized editors that produce editors for one particular PySide2.QtCore.QVariant data type (All Qt models store their data in PySide2.QtCore.QVariant s).

Standard Editing Widgets

The standard factory implementation provides editors for a variety of data types. These are created whenever a delegate needs to provide an editor for data supplied by a model. The following table shows the relationship between types and the standard editors provided.

Type Editor Widget
bool PySide2.QtWidgets.QComboBox
double PySide2.QtWidgets.QDoubleSpinBox
int PySide2.QtWidgets.QSpinBox
unsigned int
PySide2.QtCore.QDate PySide2.QtWidgets.QDateEdit
PySide2.QtCore.QDateTime PySide2.QtWidgets.QDateTimeEdit
PySide2.QtGui.QPixmap PySide2.QtWidgets.QLabel
PySide2.QtCore.QString PySide2.QtWidgets.QLineEdit
PySide2.QtCore.QTime PySide2.QtWidgets.QTimeEdit

Additional editors can be registered with the PySide2.QtWidgets.QItemEditorFactory.registerEditor() function.

class PySide2.QtWidgets.QItemEditorFactory

Constructs a new item editor factory.

PySide2.QtWidgets.QItemEditorFactory.createEditor(userType, parent)
Return type:


Creates an editor widget with the given parent for the specified userType of data, and returns it as a PySide2.QtWidgets.QWidget .

static PySide2.QtWidgets.QItemEditorFactory.defaultFactory()
Return type:PySide2.QtWidgets.QItemEditorFactory

Returns the default item editor factory.

PySide2.QtWidgets.QItemEditorFactory.registerEditor(userType, creator)

Registers an item editor creator specified by creator for the given userType of data.


The factory takes ownership of the item editor creator and will destroy it if a new creator for the same type is registered later.

static PySide2.QtWidgets.QItemEditorFactory.setDefaultFactory(factory)

Sets the default item editor factory to the given factory . Both new and existing delegates will use the new factory.

Return type:PySide2.QtCore.QByteArray

Returns the property name used to access data for the given userType of data.