QDesignerWidgetBoxInterface Class

The QDesignerWidgetBoxInterface class allows you to control the contents of Qt Designer's widget box. More...

Header: #include <QDesignerWidgetBoxInterface>
qmake: QT += designer
Inherits: QWidget

Public Functions

QDesignerWidgetBoxInterface(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags())
virtual ~QDesignerWidgetBoxInterface()
virtual void addCategory(const QDesignerWidgetBoxInterface::Category &cat) = 0
virtual void addWidget(int cat_idx, const QDesignerWidgetBoxInterface::Widget &wgt) = 0
virtual QDesignerWidgetBoxInterface::Category category(int cat_idx) const = 0
virtual int categoryCount() const = 0
virtual void dropWidgets(const QList<QDesignerDnDItemInterface *> &item_list, const QPoint &global_mouse_pos) = 0
virtual QString fileName() const = 0
virtual bool load() = 0
virtual void removeCategory(int cat_idx) = 0
virtual void removeWidget(int cat_idx, int wgt_idx) = 0
virtual bool save() = 0
virtual void setFileName(const QString &file_name) = 0
virtual QDesignerWidgetBoxInterface::Widget widget(int cat_idx, int wgt_idx) const = 0
virtual int widgetCount(int cat_idx) const = 0
  • 216 public functions inherited from QWidget

Static Public Members

const QMetaObject staticMetaObject
  • 5 static public members inherited from QWidget

Additional Inherited Members

  • 59 properties inherited from QWidget
  • 19 public slots inherited from QWidget
  • 3 signals inherited from QWidget
  • 35 protected functions inherited from QWidget
  • 1 protected slot inherited from QWidget

Detailed Description

The QDesignerWidgetBoxInterface class allows you to control the contents of Qt Designer's widget box.

QDesignerWidgetBoxInterface contains a collection of functions that is typically used to manipulate the contents of Qt Designer's widget box.

Qt Designer uses an XML file to populate its widget box. The name of that file is one of the widget box's properties, and you can retrieve it using the fileName() function.

QDesignerWidgetBoxInterface also provides the save() function that saves the contents of the widget box in the file specified by the widget box's file name property. If you have made changes to the widget box, for example by dropping a widget into the widget box, without calling the save() function, the original content can be restored by a simple invocation of the load() function:


          QDesignerWidgetBoxInterface *widgetBox = 0:
          widgetBox = formEditor->widgetBox();

          widgetBox->load();

The QDesignerWidgetBoxInterface class is not intended to be instantiated directly. You can retrieve an interface to Qt Designer's widget box using the QDesignerFormEditorInterface::widgetBox() function. A pointer to Qt Designer's current QDesignerFormEditorInterface object (formEditor in the example above) is provided by the QDesignerCustomWidgetInterface::initialize() function's parameter. When implementing a custom widget plugin, you must subclass the QDesignerCustomWidgetInterface to expose your plugin to Qt Designer.

If you want to save your changes, and at the same time preserve the original contents, you can use the save() function combined with the setFileName() function to save your changes into another file. Remember to store the name of the original file first:


          QString originalFile = widgetBox->fileName();

          widgetBox->setFileName("myWidgetBox.xml");
          widgetBox->save();

Then you can restore the original contents of the widget box by resetting the file name to the original file and calling load():


          widgetBox->setFileName(originalFile);
          widgetBox->load();

In a similar way, you can later use your customized XML file:


          if (widgetBox->filename() != "myWidgetBox.xml") {
              widgetBox->setFileName("myWidgetBox.xml");
              widgetBox->load();
          }

See also QDesignerFormEditorInterface.

Member Function Documentation

QDesignerWidgetBoxInterface::QDesignerWidgetBoxInterface(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags())

Constructs a widget box interface with the given parent and the specified window flags.

[virtual] QDesignerWidgetBoxInterface::~QDesignerWidgetBoxInterface()

Destroys the widget box interface.

[pure virtual] void QDesignerWidgetBoxInterface::addCategory(const QDesignerWidgetBoxInterface::Category &cat)

[pure virtual] void QDesignerWidgetBoxInterface::addWidget(int cat_idx, const QDesignerWidgetBoxInterface::Widget &wgt)

[pure virtual] QDesignerWidgetBoxInterface::Category QDesignerWidgetBoxInterface::category(int cat_idx) const

[pure virtual] int QDesignerWidgetBoxInterface::categoryCount() const

[pure virtual] void QDesignerWidgetBoxInterface::dropWidgets(const QList<QDesignerDnDItemInterface *> &item_list, const QPoint &global_mouse_pos)

[pure virtual] QString QDesignerWidgetBoxInterface::fileName() const

See also setFileName().

[pure virtual] bool QDesignerWidgetBoxInterface::load()

[pure virtual] void QDesignerWidgetBoxInterface::removeCategory(int cat_idx)

[pure virtual] void QDesignerWidgetBoxInterface::removeWidget(int cat_idx, int wgt_idx)

[pure virtual] bool QDesignerWidgetBoxInterface::save()

[pure virtual] void QDesignerWidgetBoxInterface::setFileName(const QString &file_name)

See also fileName().

[pure virtual] QDesignerWidgetBoxInterface::Widget QDesignerWidgetBoxInterface::widget(int cat_idx, int wgt_idx) const

[pure virtual] int QDesignerWidgetBoxInterface::widgetCount(int cat_idx) const