CopperSpice API  1.7.2
QItemEditorCreator< T > Class Template Reference

This class makes it possible to create item editor creator bases without subclassing QItemEditorCreatorBase. More...

Inheritance diagram for QItemEditorCreator< T >:
QItemEditorCreatorBase

Public Methods

 QItemEditorCreator (const QString &valuePropertyName)
 
QWidgetcreateWidget (QWidget *parent) const override
 
QString valuePropertyName () const override
 
- Public Methods inherited from QItemEditorCreatorBase
virtual ~QItemEditorCreatorBase ()
 

Detailed Description

template<class T>
class QItemEditorCreator< T >

The QItemEditorCreator class makes it possible to create item editor creator bases without subclassing QItemEditorCreatorBase. QItemEditorCreator is a convenience template class. It uses the template class to create editors for QItemEditorFactory. This way, it is not necessary to subclass QItemEditorCreatorBase.

The constructor takes the name of the property that contains the editing data. QItemDelegate can then access the property by name when it sets and retrieves editing data. Only use this class if your editor does not define a user property (using the CS_PROPERTY_USER() macro). If the widget has a user property, you should use QStandardItemEditorCreator instead.

See also
QItemEditorCreatorBase, QStandardItemEditorCreator, QItemEditorFactory

Constructor & Destructor Documentation

template<class T >
QItemEditorCreator< T >::QItemEditorCreator ( const QString valuePropertyName)
inlineexplicit

Constructs an editor creator object using valuePropertyName as the name of the property to be used for editing. The property name is used by QItemDelegate when setting and getting editor data.

Note that the valuePropertyName is only used if the editor widget does not have a user property defined.

Method Documentation

template<class T >
QWidget * QItemEditorCreator< T >::createWidget ( QWidget parent) const
inlineoverridevirtual

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.

Implements QItemEditorCreatorBase.

template<class T >
QString QItemEditorCreator< T >::valuePropertyName ( ) const
inlineoverridevirtual

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 checkable property name from this function, and must be registered in the item editor factory for the QVariant::Bool type.

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()

Implements QItemEditorCreatorBase.