QFormBuilder Class Reference

[ QtDesigner module]

The QFormBuilder class is used to dynamically construct user interfaces from UI files at run-time. 更多...

继承 QAbstractFormBuilder .

方法


详细描述

The QFormBuilder class is used to dynamically construct user interfaces from UI files at run-time.

The QFormBuilder class provides a mechanism for dynamically creating user interfaces at run-time, based on UI files created with Qt Designer 。例如:

         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);
         }
			

By including the user interface in the example's resources ( myForm.qrc ), we ensure that it will be present when the example is run:

     <!DOCTYPE RCC><RCC version="1.0">
     <qresource prefix="/forms">
        <file>mywidget.ui</file>
     </qresource>
     </RCC>
			

QFormBuilder extends the QAbstractFormBuilder base class with a number of functions that are used to support custom widget plugins:

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 class, found in the QtUiTools 模块。


方法文档编制

QFormBuilder.__init__ ( self )

Constructs a new form builder.

QFormBuilder.addPluginPath ( self , QString  pluginPath )

Adds a new plugin path specified by pluginPath 到 list of paths that will be searched by the form builder when loading a custom widget plugin.

另请参阅 setPluginPath () 和 clearPluginPaths ().

QFormBuilder.clearPluginPaths ( self )

Clears the list of paths that the form builder uses to search for custom widget plugins.

另请参阅 pluginPaths ().

list-of-QDesignerCustomWidgetInterface QFormBuilder.customWidgets ( self )

Returns a list of the available plugins.

QStringList QFormBuilder.pluginPaths ( self )

Returns the list of paths the form builder searches for 插件。

另请参阅 addPluginPath ().

QFormBuilder.setPluginPath ( self , QStringList  pluginPaths )

Sets the list of plugin paths to the list specified by pluginPaths .

另请参阅 addPluginPath ().