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
QItemEditorCreatorBase Class Referenceabstract

The QItemEditorCreatorBase class provides an abstract base class that must be subclassed when implementing new item editor creators. More...

#include <qitemeditorfactory.h>

+ Inheritance diagram for QItemEditorCreatorBase:
+ Collaboration diagram for QItemEditorCreatorBase:

Public Member Functions

virtual ~QItemEditorCreatorBase ()
 Destroys the editor creator object.
 
virtual QWidgetcreateWidget (QWidget *parent) const =0
 Returns an editor widget with the given parent.
 
virtual QByteArray valuePropertyName () const =0
 Returns the name of the property used to get and set values in the creator's editor widgets.
 

Detailed Description

The QItemEditorCreatorBase class provides an abstract base class that must be subclassed when implementing new item editor creators.

Since
4.2

\inmodule QtWidgets

QItemEditorCreatorBase objects are specialized widget factories that provide editor widgets for one particular QVariant data type. They are used by QItemEditorFactory to create editors for \l{QStyledItemDelegate}s. Creator bases must be registered with QItemEditorFactory::registerEditor().

An editor should provide a user property for the data it edits. QItemDelagates can then access the property using Qt's \l{Meta-Object System}{meta-object system} to set and retrieve the editing data. A property is set as the user property with the USER keyword:

If the editor does not provide a user property, it must return the name of the property from valuePropertyName(); delegates will then use the name to access the property. If a user property exists, item delegates will not call valuePropertyName().

QStandardItemEditorCreator is a convenience template class that can be used to register widgets without the need to subclass QItemEditorCreatorBase.

See also
QStandardItemEditorCreator, QItemEditorFactory, {Model/View Programming}

Definition at line 19 of file qitemeditorfactory.h.

Constructor & Destructor Documentation

◆ ~QItemEditorCreatorBase()

QItemEditorCreatorBase::~QItemEditorCreatorBase ( )
virtual

Destroys the editor creator object.

Definition at line 374 of file qitemeditorfactory.cpp.

Member Function Documentation

◆ createWidget()

QWidget * QItemEditorCreatorBase::createWidget ( QWidget * parent) const
pure virtual

Returns an editor widget with the given parent.

When implementing this function in subclasses of this class, you must construct and return new editor widgets with the parent widget specified.

Implemented in QItemEditorCreator< T >, and QStandardItemEditorCreator< T >.

Referenced by QItemEditorFactory::createEditor().

+ Here is the caller graph for this function:

◆ valuePropertyName()

QByteArray QItemEditorCreatorBase::valuePropertyName ( ) const
pure virtual

Returns the name of the property used to get and set values in the creator's editor widgets.

When implementing this function in subclasses, you must ensure that the editor widget's property specified by this function can accept the type the creator is registered for. For example, a creator which constructs QCheckBox widgets to edit boolean values would return the \l{QCheckBox::checkable}{checkable} property name from this function, and must be registered in the item editor factory for the QMetaType::Bool type.

Note: Since Qt 4.2 the item delegates query the user property of widgets, and only call this function if the widget has no user property. You can override this behavior by reimplementing QAbstractItemDelegate::setModelData() and QAbstractItemDelegate::setEditorData().

See also
QMetaObject::userProperty(), QItemEditorFactory::registerEditor()

Implemented in QItemEditorCreator< T >, and QStandardItemEditorCreator< T >.

Referenced by QItemEditorFactory::valuePropertyName().

+ Here is the caller graph for this function:

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