QStandardItemEditorCreator 类

template <typename T> class QStandardItemEditorCreator

QStandardItemEditorCreator 类提供注册 Widget 的可能性,不必子类化 QItemEditorCreatorBase . 更多...

头: #include <QStandardItemEditorCreator>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
继承: QItemEditorCreatorBase

公共函数

QStandardItemEditorCreator ()

重实现公共函数

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

详细描述

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

范例:

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

设置 editorFactory created above in an item delegate via QStyledItemDelegate::setItemEditorFactory () makes sure that all values of type QMetaType::QDateTime will be edited in MyFancyDateTimeEdit .

The editor must provide a user property that will contain the editing data. The property is used by QStyledItemDelegate s to set and retrieve the data (using Qt's 元对象系统 ). You set the user property with the USER keyword:

Q_PROPERTY(QColor color READ color WRITE setColor USER true)
					

另请参阅 QItemEditorCreatorBase , QItemEditorCreator , QItemEditorFactory , QStyledItemDelegate ,和 色彩编辑器工厂范例 .

成员函数文档编制

QStandardItemEditorCreator:: QStandardItemEditorCreator ()

Constructs an editor creator object.

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

重实现: QItemEditorCreatorBase::createWidget(QWidget *parent) const .

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

重实现: QItemEditorCreatorBase::valuePropertyName() const .