QDesignerCustomWidgetCollectionInterface Class
QDesignerCustomWidgetCollectionInterface 클래스를 사용하면 하나의 라이브러리에 여러 개의 사용자 정의 위젯을 포함할 수 있습니다. 더 보기...
| 헤더: | #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`, ` CustomWidgetTwo `, ` CustomWidgetThree`와 같은 여러 사용자 정의 위젯이 있는 경우, 클래스 정의는 다음과 같을 수 있습니다:
#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 default] QDesignerCustomWidgetCollectionInterface::~QDesignerCustomWidgetCollectionInterface()
사용자 정의 위젯 컬렉션 인터페이스를 삭제합니다.
[pure virtual] QList<QDesignerCustomWidgetInterface *> QDesignerCustomWidgetCollectionInterface::customWidgets() const
컬렉션의 사용자 정의 위젯에 대한 인터페이스 목록을 반환합니다.
© 2026 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.