QDesignerWidgetBoxInterface Class
La clase QDesignerWidgetBoxInterface permite controlar el contenido de la caja de widgets de Qt Widgets Designer. Más...
| Cabecera: | #include <QDesignerWidgetBoxInterface> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Designer)target_link_libraries(mytarget PRIVATE Qt6::Designer) |
| qmake: | QT += designer |
| Hereda: | QWidget |
Funciones Públicas
| 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 |
Descripción Detallada
QDesignerWidgetBoxInterface contiene una colección de funciones que se utilizan normalmente para manipular el contenido de la caja de widgets de Qt Widgets Designer.
Qt Widgets Designer usa un archivo XML para rellenar su caja de widgets. El nombre de ese archivo es una de las propiedades de la caja de widgets, y puedes recuperarlo usando la función fileName().
QDesignerWidgetBoxInterface también proporciona la función save() que guarda el contenido de la caja widget en el archivo especificado por la propiedad nombre de archivo de la caja widget. Si se han realizado cambios en la caja de widgets, por ejemplo soltando un widget en la caja de widgets, sin llamar a la función save(), el contenido original puede restaurarse con una simple invocación a la función load():
auto *widgetBox = formEditor->widgetBox(); widgetBox->load();
La clase QDesignerWidgetBoxInterface no está pensada para ser instanciada directamente. Puede recuperar una interfaz a Qt Designer's widget box utilizando la función QDesignerFormEditorInterface::widgetBox(). El parámetro de la función QDesignerCustomWidgetInterface::initialize() proporciona un puntero al objeto QDesignerFormEditorInterface actual de Qt Widgets Designer (formEditor en el ejemplo anterior). Al implementar un plugin de widget personalizado, debe subclasificar el QDesignerCustomWidgetInterface para exponer su plugin a Qt Widgets Designer.
Si quieres guardar tus cambios, y al mismo tiempo preservar el contenido original, puedes usar la función save() combinada con la función setFileName() para guardar tus cambios en otro archivo. Recuerda guardar primero el nombre del archivo original:
QString originalFile = widgetBox->fileName(); widgetBox->setFileName("myWidgetBox.xml"); widgetBox->save();
A continuación, puede restaurar el contenido original del cuadro de widgets restableciendo el nombre del archivo original y llamando a load():
widgetBox->setFileName(originalFile); widgetBox->load();
De forma similar, puedes utilizar posteriormente tu archivo XML personalizado:
if (widgetBox->filename() != "myWidgetBox.xml") { widgetBox->setFileName("myWidgetBox.xml"); widgetBox->load(); }
Véase también QDesignerFormEditorInterface.
Documentación de las funciones miembro
[explicit] QDesignerWidgetBoxInterface::QDesignerWidgetBoxInterface(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags())
Construye una interfaz de caja de widget con el parent dado y la ventana especificada flags.
[override virtual noexcept] QDesignerWidgetBoxInterface::~QDesignerWidgetBoxInterface()
Destruye la interfaz de la caja de widgets.
[pure virtual] QString QDesignerWidgetBoxInterface::fileName() const
Devuelve el nombre del archivo XML que Qt Widgets Designer está utilizando actualmente para rellenar su cuadro de widgets.
Véase también setFileName().
[pure virtual] bool QDesignerWidgetBoxInterface::load()
Rellena el cuadro de widgets de Qt Widgets Designer cargando (o recargando) el archivo XML especificado actualmente. Devuelve true si el archivo se ha cargado correctamente; en caso contrario, false.
Véase también setFileName().
[pure virtual] bool QDesignerWidgetBoxInterface::save()
Guarda el contenido de la caja de widgets de Qt Widgets Designer en el archivo especificado por la función fileName(). Devuelve true si el contenido se ha guardado correctamente; en caso contrario, false.
Véase también fileName() y setFileName().
[pure virtual] void QDesignerWidgetBoxInterface::setFileName(const QString &fileName)
Establece el archivo XML que Qt Widgets Designer utilizará para rellenar su cuadro de widgets, en fileName. Debe llamar a load() para actualizar el cuadro de widgets con el nuevo archivo XML.
© 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.