QItemEditorCreatorBase Class
QItemEditorCreatorBase 클래스는 새로운 아이템 에디터 크리에이터를 구현할 때 서브클래싱해야 하는 추상 베이스 클래스를 제공합니다. 더 보기...
Header: | #include <QItemEditorCreatorBase> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
상속됨: |
공용 함수
virtual | ~QItemEditorCreatorBase() |
virtual QWidget * | createWidget(QWidget *parent) const = 0 |
virtual QByteArray | valuePropertyName() const = 0 |
상세 설명
QItemEditorCreatorBase 객체는 특정 QVariant 데이터 유형에 대한 편집기 위젯을 제공하는 특수 위젯 팩토리입니다. QItemEditorFactory 에서 QStyledItemDelegate에 대한 에디터를 생성하는 데 사용됩니다. 크리에이터 베이스는 QItemEditorFactory::registerEditor()에 등록해야 합니다.
편집기는 편집하는 데이터에 대한 사용자 속성을 제공해야 합니다. 그러면 QItemDelagates는 Qt의 메타 객체 시스템을 사용하여 프로퍼티에 액세스하여 편집 데이터를 설정하고 검색할 수 있습니다. 프로퍼티는 USER 키워드를 사용하여 사용자 프로퍼티로 설정됩니다:
Q_PROPERTY(QColor color READ color WRITE setColor USER true)
편집기가 사용자 속성을 제공하지 않는 경우 valuePropertyName()에서 속성 이름을 반환해야 하며, 델리게이트는 이 이름을 사용하여 속성에 액세스합니다. 사용자 속성이 존재하면 항목 델리게이트는 valuePropertyName()를 호출하지 않습니다.
QStandardItemEditorCreator 는 위젯을 등록하는 데 사용할 수 있는 편리한 템플릿 클래스로, QItemEditorCreatorBase를 서브클래싱할 필요 없이 사용할 수 있습니다.
QStandardItemEditorCreator, QItemEditorFactory, 및 모델/보기 프로그래밍을참조하십시오 .
멤버 함수 문서
[virtual noexcept]
QItemEditorCreatorBase::~QItemEditorCreatorBase()
편집기 생성자 개체를 삭제합니다.
[pure virtual]
QWidget *QItemEditorCreatorBase::createWidget(QWidget *parent) const
지정된 parent 로 편집기 위젯을 반환합니다.
이 클래스의 서브클래스에서 이 함수를 구현할 때는 부모 위젯을 지정하여 새 에디터 위젯을 생성하고 반환해야 합니다.
[pure virtual]
QByteArray QItemEditorCreatorBase::valuePropertyName() const
크리에이터의 에디터 위젯에서 값을 가져오고 설정하는 데 사용되는 프로퍼티의 이름을 반환합니다.
서브클래스에서 이 함수를 구현할 때는 이 함수가 지정한 에디터 위젯의 프로퍼티가 크리에이터가 등록한 유형을 받아들일 수 있는지 확인해야 합니다. 예를 들어, 부울 값을 편집하는 QCheckBox 위젯을 생성하는 크리에이터는 이 함수에서 checkable 속성 이름을 반환하며, 아이템 에디터 팩토리에 QMetaType::Bool 유형으로 등록되어 있어야 합니다.
참고: Qt 4.2부터 아이템 델리게이트는 위젯의 사용자 프로퍼티를 쿼리하며, 위젯에 사용자 프로퍼티가 없는 경우에만 이 함수를 호출합니다. QAbstractItemDelegate::setModelData () 및 QAbstractItemDelegate::setEditorData()을 다시 구현하여 이 동작을 재정의할 수 있습니다.
QMetaObject::userProperty() 및 QItemEditorFactory::registerEditor()도 참조하세요 .
© 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.