QItemEditorCreator Class
template <typename T> class QItemEditorCreator通过 QItemEditorCreator 类,无需子类化QItemEditorCreatorBase 即可创建项目编辑器创建器库。更多
Header: | #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 是一个方便的模板类。它使用模板类为QItemEditorFactory 创建编辑器。这样,就无需子类化QItemEditorCreatorBase 。
QItemEditorCreator<MyEditor> *itemCreator = new QItemEditorCreator<MyEditor>("myProperty"); QItemEditorFactory *factory = new QItemEditorFactory;
构造函数接收包含编辑数据的属性名称。然后,当QStyledItemDelegate 设置和检索编辑数据时,可以通过名称访问该属性。只有当编辑器未定义用户属性(使用Q_PROPERTY 宏中的 USER 关键字)时,才可使用该类。如果 widget 有用户属性,则应使用QStandardItemEditorCreator 代替。
另请参阅 QItemEditorCreatorBase,QStandardItemEditorCreator, 和QItemEditorFactory 。
成员函数文档
[explicit]
QItemEditorCreator::QItemEditorCreator(const QByteArray &valuePropertyName)
使用valuePropertyName 作为用于编辑的属性名称,构造编辑器创建者对象。QStyledItemDelegate 在设置和获取编辑器数据时会使用该属性名。
请注意,只有在编辑器部件未定义用户属性时,才会使用valuePropertyName 。
[override virtual]
QWidget *QItemEditorCreator::createWidget(QWidget *parent) const
重实现:QItemEditorCreatorBase::createWidget(QWidget *parent) const.
[override virtual]
QByteArray QItemEditorCreator::valuePropertyName() const
重实现:QItemEditorCreatorBase::valuePropertyName() const.
© 2025 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.