QItemEditorCreator 类使之可能创建项编辑器创建者库,无需子类化 QItemEditorCreatorBase . 更多...
头: | #include <QItemEditorCreator> |
CMake: |
find_package(Qt6 COMPONENTS Widgets REQUIRED)
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 ,和 色彩编辑器工厂范例 .
构造编辑器创建者对象使用 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.