Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

QAbstractFormBuilder Class

The QAbstractFormBuilder class provides a default implementation for classes that create user interfaces at run-time. More...

Header: #include <QAbstractFormBuilder>
qmake: QT += designer
Inherited By:


Public Functions

virtual ~QAbstractFormBuilder()
QString errorString() const
virtual QWidget * load(QIODevice *device, QWidget *parent = Q_NULLPTR)
virtual void save(QIODevice *device, QWidget *widget)
void setWorkingDirectory(const QDir &directory)
QDir workingDirectory() const

Protected Types

typedef DomPropertyHash
typedef IconPaths

Detailed Description

The QAbstractFormBuilder class provides a default implementation for classes that create user interfaces at run-time.

QAbstractFormBuilder provides a standard interface and a default implementation for constructing forms from user interface files. It is not intended to be instantiated directly. Use the QFormBuilder class to create user interfaces from UI files at run-time. For example:

        MyForm::MyForm(QWidget *parent)
            : QWidget(parent)
            QFormBuilder builder;
            QFile file(":/forms/myWidget.ui");
            QWidget *myWidget = builder.load(&file, this);

            QVBoxLayout *layout = new QVBoxLayout;

To override certain aspects of the form builder's behavior, subclass QAbstractFormBuilder and reimplement the relevant virtual functions:

  • load() handles reading of UI format files from arbitrary QIODevices, and construction of widgets from the XML data that they contain.
  • save() handles saving of widget details in UI format to arbitrary QIODevices.
  • workingDirectory() and setWorkingDirectory() control the directory in which forms are held. The form builder looks for other resources on paths relative to this directory.

The QFormBuilder class is typically used by custom components and applications that embed Qt Designer. Standalone applications that need to dynamically generate user interfaces at run-time use the QUiLoader, found in the Qt UI Tools module.

See also Qt UI Tools.

Member Function Documentation


Constructs a new form builder.

[virtual] QAbstractFormBuilder::~QAbstractFormBuilder()

Destroys the form builder.

QString QAbstractFormBuilder::errorString() const

Returns a human-readable description of the last error occurred in load().

This function was introduced in Qt 5.0.

See also load().

[virtual] QWidget *QAbstractFormBuilder::load(QIODevice *device, QWidget *parent = Q_NULLPTR)

Loads an XML representation of a widget from the given device, and constructs a new widget with the specified parent.

See also save() and errorString().

[virtual] void QAbstractFormBuilder::save(QIODevice *device, QWidget *widget)

Saves an XML representation of the given widget to the specified device in the standard UI file format.

See also load().

void QAbstractFormBuilder::setWorkingDirectory(const QDir &directory)

Sets the current working directory of the form builder to the specified directory.

See also workingDirectory().

QDir QAbstractFormBuilder::workingDirectory() const

Returns the current working directory of the form builder.

See also setWorkingDirectory().

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded