QStandardItemEditorCreator Class

template <typename T> class QStandardItemEditorCreator

The QStandardItemEditorCreator class provides the possibility to register widgets without having to subclass QItemEditorCreatorBase. More...

Header: #include <QStandardItemEditorCreator>
qmake: QT += widgets
Since: Qt 4.2
Inherits: QItemEditorCreatorBase

This class was introduced in Qt 4.2.

Public Functions

Reimplemented Public Functions

virtual QWidget *createWidget(QWidget *parent) const override
virtual QByteArray valuePropertyName() const override

Detailed Description

This convenience template class makes it possible to register widgets without having to subclass QItemEditorCreatorBase.

Example:

QItemEditorFactory *editorFactory = new QItemEditorFactory;
QItemEditorCreatorBase *creator = new QStandardItemEditorCreator<MyFancyDateTimeEdit>();
editorFactory->registerEditor(QVariant::DateType, creator);

Setting the editorFactory created above in an item delegate via QStyledItemDelegate::setItemEditorFactory() makes sure that all values of type QVariant::DateTime will be edited in MyFancyDateTimeEdit.

The editor must provide a user property that will contain the editing data. The property is used by QStyledItemDelegates to set and retrieve the data (using Qt's meta-object system). You set the user property with the USER keyword:

Q_PROPERTY(QColor color READ color WRITE setColor USER true)

See also QItemEditorCreatorBase, QItemEditorCreator, QItemEditorFactory, QStyledItemDelegate, and Color Editor Factory Example.

Member Function Documentation

QStandardItemEditorCreator::QStandardItemEditorCreator()

Constructs an editor creator object.

[override virtual] QWidget *QStandardItemEditorCreator::createWidget(QWidget *parent) const

Reimplements: QItemEditorCreatorBase::createWidget(QWidget *parent) const.

[override virtual] QByteArray QStandardItemEditorCreator::valuePropertyName() const

Reimplements: QItemEditorCreatorBase::valuePropertyName() const.

© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.