The QAbstractFormBuilder class provides a default implementation for classes that create user interfaces at run-time. 更多...
| 頭: | #include <QAbstractFormBuilder> |
| qmake: | QT += designer |
| 繼承者: | QFormBuilder |
| QAbstractFormBuilder () | |
| 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 |
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");
file.open(QFile::ReadOnly);
QWidget *myWidget = builder.load(&file, this);
file.close();
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(myWidget);
setLayout(layout);
}
To override certain aspects of the form builder's behavior, subclass QAbstractFormBuilder and reimplement the relevant virtual functions:
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 模塊。
另請參閱 Qt UI Tools .
Constructs a new form builder.
[虛擬]
QAbstractFormBuilder::
~QAbstractFormBuilder
()
Destroys the form builder.
Returns a human-readable description of the last error occurred in load ().
該函數在 Qt 5.0 引入。
另請參閱 load ().
[虛擬]
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 .
另請參閱 save () 和 errorString ().
[虛擬]
void
QAbstractFormBuilder::
save
(
QIODevice
*
device
,
QWidget
*
widget
)
Saves an XML representation of the given widget 到指定 device in the standard UI file format.
另請參閱 load ().
Sets the current working directory of the form builder to the specified directory .
另請參閱 workingDirectory ().
Returns the current working directory of the form builder.
另請參閱 setWorkingDirectory ().