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() |
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 XML 파일을 사용하여 위젯 상자를 채웁니다. 해당 파일의 이름은 위젯 상자의 속성 중 하나이며 fileName() 함수를 사용하여 검색할 수 있습니다.
또한 위젯 상자의 파일 이름 속성으로 지정된 파일에 위젯 상자의 내용을 저장하는 save() 함수도 제공합니다. 예를 들어 위젯 상자에 위젯을 끌어다 놓는 등 위젯 상자를 변경한 경우 save() 함수를 호출하지 않고 load() 함수를 간단히 호출하여 원래 내용을 복원할 수 있습니다:
auto *widgetBox = formEditor->widgetBox(); widgetBox->load();
QDesignerWidgetBoxInterface 클래스는 직접 인스턴스화할 수 없습니다. QDesignerFormEditorInterface::widgetBox () 함수를 사용하여 Qt Designer 의 위젯 상자에 대한 인터페이스를 검색할 수 있습니다. Qt Widgets Designer 의 현재 QDesignerFormEditorInterface 객체(위 예시에서는formEditor
)에 대한 포인터는 QDesignerCustomWidgetInterface::initialize() 함수의 파라미터로 제공됩니다. 사용자 정의 위젯 플러그인을 구현할 때는 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 으로 위젯 상자 인터페이스를 구축합니다.
[virtual noexcept]
QDesignerWidgetBoxInterface::~QDesignerWidgetBoxInterface()
위젯 상자 인터페이스를 삭제합니다.
[pure virtual]
QString QDesignerWidgetBoxInterface::fileName() const
Qt Widgets Designer 가 현재 위젯 상자를 채우는 데 사용하고 있는 XML 파일의 이름을 반환합니다.
setFileName()도 참조하세요 .
[pure virtual]
bool QDesignerWidgetBoxInterface::load()
현재 지정된 XML 파일을 로드(또는 다시 로드)하여 Qt Widgets Designer 의 위젯 상자를 채웁니다. 파일이 성공적으로 로드되면 참을 반환하고, 그렇지 않으면 거짓을 반환합니다.
setFileName()도 참조하세요 .
[pure virtual]
bool QDesignerWidgetBoxInterface::save()
fileName() 함수에 지정된 파일에 Qt Widgets Designer 의 위젯 상자 내용을 저장합니다. 콘텐츠가 성공적으로 저장되면 참을 반환하고, 그렇지 않으면 거짓을 반환합니다.
fileName() 및 setFileName()도 참조하세요 .
[pure virtual]
void QDesignerWidgetBoxInterface::setFileName(const QString &fileName)
Qt Widgets Designer 에서 위젯 상자를 채우는 데 사용할 XML 파일을 fileName 으로 설정합니다. 위젯 상자를 새 XML 파일로 업데이트하려면 load()를 호출해야 합니다.
© 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.