Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QItemEditorFactory Class Reference

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

#include <qitemeditorfactory.h>

+ Inheritance diagram for QItemEditorFactory:
+ Collaboration diagram for QItemEditorFactory:

Public Member Functions

 QItemEditorFactory ()
 Constructs a new item editor factory.
 
virtual ~QItemEditorFactory ()
 Destroys the item editor factory.
 
virtual QWidgetcreateEditor (int userType, QWidget *parent) const
 Creates an editor widget with the given parent for the specified userType of data, and returns it as a QWidget.
 
virtual QByteArray valuePropertyName (int userType) const
 Returns the property name used to access data for the given userType of data.
 
void registerEditor (int userType, QItemEditorCreatorBase *creator)
 Registers an item editor creator specified by creator for the given userType of data.
 

Static Public Member Functions

static const QItemEditorFactorydefaultFactory ()
 Returns the default item editor factory.
 
static void setDefaultFactory (QItemEditorFactory *factory)
 [2]
 

Detailed Description

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

Since
4.2

\inmodule QtWidgets

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

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

Definition at line 59 of file qitemeditorfactory.h.

Constructor & Destructor Documentation

◆ QItemEditorFactory()

QItemEditorFactory::QItemEditorFactory ( )
inline

Constructs a new item editor factory.

Definition at line 62 of file qitemeditorfactory.h.

◆ ~QItemEditorFactory()

QItemEditorFactory::~QItemEditorFactory ( )
virtual

Destroys the item editor factory.

Definition at line 164 of file qitemeditorfactory.cpp.

References QHash< Key, T >::cbegin(), QHash< Key, T >::cend(), it, and qDeleteAll().

+ Here is the call graph for this function:

Member Function Documentation

◆ createEditor()

QWidget * QItemEditorFactory::createEditor ( int userType,
QWidget * parent ) const
virtual

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

See also
registerEditor()

Reimplemented in QDefaultItemEditorFactory.

Definition at line 138 of file qitemeditorfactory.cpp.

References QItemEditorCreatorBase::createWidget(), creator, defaultFactory(), nullptr, and QHash< Key, T >::value().

Referenced by QItemDelegate::createEditor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ defaultFactory()

const QItemEditorFactory * QItemEditorFactory::defaultFactory ( )
static

Returns the default item editor factory.

See also
setDefaultFactory()

Definition at line 314 of file qitemeditorfactory.cpp.

References factory, and q_default_factory.

Referenced by createEditor(), QItemDelegate::createEditor(), QItemDelegatePrivate::editorFactory(), QStyledItemDelegatePrivate::editorFactory(), and valuePropertyName().

+ Here is the caller graph for this function:

◆ registerEditor()

void QItemEditorFactory::registerEditor ( int userType,
QItemEditorCreatorBase * creator )

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

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

See also
createEditor()

Definition at line 182 of file qitemeditorfactory.cpp.

References QHash< Key, T >::cbegin(), QHash< Key, T >::cend(), QHash< Key, T >::constFind(), creator, QHash< Key, T >::erase(), it, and Q_ASSERT.

+ Here is the call graph for this function:

◆ setDefaultFactory()

void QItemEditorFactory::setDefaultFactory ( QItemEditorFactory * factory)
static

[2]

Sets the default item editor factory to the given factory.

Both new and existing delegates will use the new factory.

See also
defaultFactory()

Definition at line 328 of file qitemeditorfactory.cpp.

References factory, and q_default_factory.

◆ valuePropertyName()

QByteArray QItemEditorFactory::valuePropertyName ( int userType) const
virtual

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

Reimplemented in QDefaultItemEditorFactory.

Definition at line 151 of file qitemeditorfactory.cpp.

References creator, defaultFactory(), QByteArray(), QHash< Key, T >::value(), and QItemEditorCreatorBase::valuePropertyName().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: