![]() |
Qt 6.x
The Qt SDK
|
The QItemEditorFactory class provides widgets for editing item data in views and delegates. More...
#include <qitemeditorfactory.h>
Public Member Functions | |
QItemEditorFactory () | |
Constructs a new item editor factory. | |
virtual | ~QItemEditorFactory () |
Destroys the item editor factory. | |
virtual QWidget * | createEditor (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 QItemEditorFactory * | defaultFactory () |
Returns the default item editor factory. | |
static void | setDefaultFactory (QItemEditorFactory *factory) |
Sets the default item editor factory to the given factory. | |
The QItemEditorFactory class provides widgets for editing item data in views and delegates.
\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.
|
inline |
Constructs a new item editor factory.
Definition at line 62 of file qitemeditorfactory.h.
|
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().
Creates an editor widget with the given parent for the specified userType of data, and returns it as a QWidget.
Reimplemented in QDefaultItemEditorFactory.
Definition at line 138 of file qitemeditorfactory.cpp.
References createEditor(), QItemEditorCreatorBase::createWidget(), creator, defaultFactory(), nullptr, parent, and QHash< Key, T >::value().
Referenced by createEditor(), and QItemDelegate::createEditor().
|
static |
Returns the default item editor factory.
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().
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.
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.
|
static |
Sets the default item editor factory to the given factory.
Both new and existing delegates will use the new factory.
Definition at line 328 of file qitemeditorfactory.cpp.
References factory, and q_default_factory.
|
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(), QHash< Key, T >::value(), QItemEditorCreatorBase::valuePropertyName(), and valuePropertyName().
Referenced by valuePropertyName().