QItemEditorCreator 类

template <typename T> class QItemEditorCreator

QItemEditorCreator 类使之可能创建项编辑器创建者库,无需子类化 QItemEditorCreatorBase . 更多...

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

公共函数

QItemEditorCreator (const QByteArray & valuePropertyName )

重实现公共函数

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

详细描述

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 .

QItemEditorCreator<MyEditor> *itemCreator =
    new QItemEditorCreator<MyEditor>("myProperty");
QItemEditorFactory *factory = new QItemEditorFactory;
					

The constructor takes the name of the property that contains the editing data. QStyledItemDelegate 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 USER keyword in the Q_PROPERTY macro). If the widget has a user property, you should use QStandardItemEditorCreator 代替。

另请参阅 QItemEditorCreatorBase , QStandardItemEditorCreator ,和 QItemEditorFactory .

成员函数文档编制

[explicit] QItemEditorCreator:: QItemEditorCreator (const QByteArray & valuePropertyName )

构造编辑器创建者对象使用 valuePropertyName 作为要用于编辑的特性名。特性名用于 QStyledItemDelegate 当设置和获取编辑器数据时。

注意, valuePropertyName is only used if the editor widget does not have a user property defined.

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

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

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

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