QDesignerCustomWidgetCollectionInterface Class

QDesignerCustomWidgetCollectionInterface 클래스를 사용하면 하나의 라이브러리에 여러 사용자 정의 위젯을 포함할 수 있습니다. 더 보기...

Header: #include <QDesignerCustomWidgetCollectionInterface>
CMake: find_package(Qt6 REQUIRED COMPONENTS Designer)
target_link_libraries(mytarget PRIVATE Qt6::Designer)
qmake: QT += designer

공용 함수

virtual ~QDesignerCustomWidgetCollectionInterface()
virtual QList<QDesignerCustomWidgetInterface *> customWidgets() const = 0

상세 설명

사용자 정의 위젯 플러그인을 구현할 때는 별도의 라이브러리로 빌드합니다. 같은 라이브러리에 여러 사용자 정의 위젯 플러그인을 포함하려면 QDesignerCustomWidgetCollectionInterface 서브클래스를 추가해야 합니다.

QDesignerCustomWidgetCollectionInterface에는 컬렉션의 QDesignerCustomWidgetInterface 객체 목록을 반환하는 단일 함수가 포함되어 있습니다. 예를 들어 CustomWidgetOne, CustomWidgetTwoCustomWidgetThree 라는 사용자 지정 위젯이 여러 개 있는 경우 클래스 정의는 다음과 같을 수 있습니다:

#include customwidgetoneinterface.h
#include customwidgettwointerface.h
#include customwidgetthreeinterface.h

#include <QtDesigner/qtdesigner.h>
#include <QtCore/qplugin.h>

class MyCustomWidgets: public QObject, public QDesignerCustomWidgetCollectionInterface
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface")
    Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)

public:
    MyCustomWidgets(QObject *parent = 0);

    QList<QDesignerCustomWidgetInterface*> customWidgets() const override;

private:
    QList<QDesignerCustomWidgetInterface*> widgets;
};

클래스 생성자에서 사용자 정의 위젯의 인터페이스를 customWidgets() 함수에서 반환하는 목록에 추가합니다:

MyCustomWidgets::MyCustomWidgets(QObject *parent)
        : QObject(parent)
{
    widgets.append(new CustomWidgetOneInterface(this));
    widgets.append(new CustomWidgetTwoInterface(this));
    widgets.append(new CustomWidgetThreeInterface(this));
}

QList<QDesignerCustomWidgetInterface*> MyCustomWidgets::customWidgets() const
{
    return widgets;
}

Q_PLUGIN_METADATA() 매크로를 사용하여 각 사용자 정의 위젯 플러그인을 내보내는 대신 전체 컬렉션을 내보냅니다. Q_PLUGIN_METADATA () 매크로는 Qt Widgets Designer 에서 사용자 정의 위젯에 액세스하고 구성할 수 있도록 합니다. 이 매크로가 없으면 Qt Widgets Designer 에서 사용자 정의 위젯을 사용할 수 없습니다.

QDesignerCustomWidgetInterface Qt Widgets Designer 에 대한 사용자 정의 위젯 만들기를참조하세요 .

멤버 함수 문서

[virtual constexpr noexcept] QDesignerCustomWidgetCollectionInterface::~QDesignerCustomWidgetCollectionInterface()

사용자 정의 위젯 컬렉션 인터페이스를 삭제합니다.

[pure virtual] QList<QDesignerCustomWidgetInterface *> QDesignerCustomWidgetCollectionInterface::customWidgets() 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.