QDesignerWidgetBoxInterface Class
QDesignerWidgetBoxInterface 클래스를 사용하면 Qt Widgets Designer 의 위젯 상자 내용을 제어할 수 있습니다. 더 보기...
| 헤더: | #include <QDesignerWidgetBoxInterface> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Designer) target_link_libraries(mytarget PRIVATE Qt6::Designer) |
| qmake: | QT += designer |
| 상속: | QWidget |
공개 함수
| QDesignerWidgetBoxInterface(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()) | |
| virtual | ~QDesignerWidgetBoxInterface() override |
| virtual QString | fileName() const = 0 |
| virtual bool | load() = 0 |
| virtual bool | save() = 0 |
| virtual void | setFileName(const QString &fileName) = 0 |
상세 설명
QDesignerWidgetBoxInterface는 일반적으로 Qt Widgets Designer 의 위젯 상자 내용을 조작하는 데 사용되는 일련의 함수들을 포함합니다.
Qt Widgets Designer fileName 는 XML 파일을 사용하여 위젯 박스를 채웁니다. 해당 파일의 이름은 위젯 박스의 속성 중 하나이며, () 함수를 사용하여 이를 가져올 수 있습니다.
QDesignerWidgetBoxInterface는 또한 위젯 상자의 내용을 위젯 상자의 파일 이름 속성으로 지정된 파일에 저장하는 save() 함수도 제공합니다. save() 함수를 호출하지 않은 상태에서 위젯을 위젯 박스에 드롭하는 등 위젯 박스에 변경 사항을 적용한 경우, load() 함수를 간단히 호출하여 원래 내용을 복원할 수 있습니다:
auto *widgetBox = formEditor->widgetBox();
widgetBox->load();QDesignerWidgetBoxInterface 클래스는 직접 인스턴스화하도록 의도되지 않았습니다. QDesignerFormEditorInterface::widgetBox() 함수를 사용하여 Qt Designer 의 위젯 상자에 대한 인터페이스를 가져올 수 있습니다. QDesignerCustomWidgetInterface::initialize() 함수의 매개변수를 통해 Qt Widgets Designer 의 현재 QDesignerFormEditorInterface 객체(위 예제에서는formEditor )에 대한 포인터가 제공됩니다. 사용자 정의 위젯 플러그인을 구현할 때는 QDesignerCustomWidgetInterface 를 서브클래싱하여 Qt Widgets Designer 에 플러그인을 노출해야 합니다.
변경 사항을 저장하면서 원본 내용을 보존하려면, ` save()` 함수와 ` setFileName()` 함수를 함께 사용하여 변경 사항을 다른 파일에 저장할 수 있습니다. 먼저 원본 파일의 이름을 저장하는 것을 잊지 마십시오:
QString originalFile = widgetBox->fileName();
widgetBox->setFileName("myWidgetBox.xml");
widgetBox->save();그런 다음 파일 이름을 원래 파일명으로 재설정하고 load()를 호출하여 위젯 박스의 원래 내용을 복원할 수 있습니다:
widgetBox->setFileName(originalFile);
widgetBox->load();이와 유사한 방식으로, 나중에 사용자 정의 XML 파일을 사용할 수 있습니다:
if (widgetBox->filename() != "myWidgetBox.xml") {
widgetBox->setFileName("myWidgetBox.xml");
widgetBox->load();
}QDesignerFormEditorInterface도 참조하십시오 .
멤버 함수 문서
[explicit] QDesignerWidgetBoxInterface::QDesignerWidgetBoxInterface(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags())
지정된 parent 및 지정된 창 flags 을 사용하여 위젯 박스 인터페이스를 생성합니다.
[override virtual noexcept] QDesignerWidgetBoxInterface::~QDesignerWidgetBoxInterface()
위젯 박스 인터페이스를 제거합니다.
[pure virtual] QString QDesignerWidgetBoxInterface::fileName() const
Qt Widgets Designer 가 현재 위젯 박스를 채우는 데 사용하고 있는 XML 파일의 이름을 반환합니다.
setFileName()도 참조하십시오 .
[pure virtual] bool QDesignerWidgetBoxInterface::load()
현재 지정된 XML 파일을 불러오거나(또는 다시 불러오거나) 하여 Qt Widgets Designer 의 위젯 상자를 채웁니다. 파일이 성공적으로 불러오면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
setFileName()도 참조하십시오 .
[pure virtual] bool QDesignerWidgetBoxInterface::save()
Qt Widgets Designer 의 위젯 상자 내용을 fileName() 함수가 지정한 파일에 저장합니다. 내용이 성공적으로 저장되면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
fileName() 및 setFileName()도 참조하십시오 .
[pure virtual] void QDesignerWidgetBoxInterface::setFileName(const QString &fileName)
Qt Widgets Designer 가 위젯 상자를 채우는 데 사용할 XML 파일을 fileName 로 설정합니다. 새로운 XML 파일로 위젯 상자를 업데이트하려면 load()를 호출해야 합니다.
© 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.