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 QDesignerWidgetBoxInterfaceは、ウィジェット・ボックスにXMLファイルを入力します。そのファイル名はウィジェット・ボックスのプロパティの1つで、fileName() 関数を使用して取得できます。
QDesignerWidgetBoxInterfaceには、ウィジェット・ボックスのファイル名プロパティで指定されたファイルにウィジェット・ボックスの内容を保存するsave ()関数も用意されています。save ()関数を呼び出さずにウィジェット・ボックスにウィジェットをドロップするなどしてウィジェット・ボックスに変更を加えた場合、load ()関数を呼び出すだけで元の内容を復元することができます:
auto *widgetBox = formEditor->widgetBox(); widgetBox->load();
QDesignerWidgetBoxInterfaceクラスは、直接インスタンス化することを意図していません。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 を持つウィジェットボックスインターフェイスを構築します。
[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()
fileName() 関数で指定されたファイルにQt Widgets Designer のウィジェット・ボックスの内容を保存します。内容の保存に成功した場合は 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.