QFormBuilder Class Reference

[QtDesigner module]

该QFormBuilder类用于在运行时动态地构建用户界面的UI文件。More…

继承QAbstractFormBuilder

Methods

  • __init__ (self)
  • addPluginPath (self, QString pluginPath)
  • clearPluginPaths (self)
  • list-of-QDesignerCustomWidgetInterface customWidgets (self)
  • QStringList pluginPaths (self)
  • setPluginPath (self, QStringList pluginPaths)

Detailed Description

该QFormBuilder类用于在运行时动态地构建用户界面的UI文件。

该QFormBuilder类提供了一种机制,在运行时动态地创建用户界面的基础上,以创建UI文件Qt Designer。例如:

  1. MyForm.MyForm([QWidget](qwidget.html) *parent)
  2. : [QWidget](qwidget.html)(parent)
  3. {
  4. QFormBuilder builder;
  5. [QFile](qfile.html) file(":/forms/myWidget.ui");
  6. file.open([QFile](qfile.html).ReadOnly);
  7. [QWidget](qwidget.html) *myWidget = builder.load(&file, this);
  8. file.close();
  9. [QVBoxLayout](qvboxlayout.html) *layout = new [QVBoxLayout](qvboxlayout.html);
  10. layout->addWidget(myWidget);
  11. setLayout(layout);
  12. }

通过包括在该示例的资源的用户界面(myForm.qrc) ,我们保证这将是目前的例子运行时:

  1. <!DOCTYPE RCC><RCC version="1.0">
  2. <qresource prefix="/forms">
  3. <file>mywidget.ui</file>
  4. </qresource>
  5. </RCC>

QFormBuilder扩展QAbstractFormBuilder与一些用来支持自定义窗口小部件插件功能的基类:

  • pluginPaths() returns the list of paths that the form builder searches when loading custom widget plugins.
  • addPluginPath() allows additional paths to be registered with the form builder.
  • setPluginPath() is used to replace the existing list of paths with a list obtained from some other source.
  • clearPluginPaths() removes all paths registered with the form builder.
  • customWidgets() returns a list of interfaces to plugins that can be used to create new instances of registered custom widgets.

该QFormBuilder类通常由定制组件和应用程序嵌入Qt Designer。需要动态生成用户界面在运行时独立应用程序使用QUiLoader类,在发现QtUiTools模块。


Method Documentation

  1. QFormBuilder.__init__ (self)

构造一个新的表单生成器。

  1. QFormBuilder.addPluginPath (self, QString pluginPath)

通过添加指定一个新的插件路径pluginPath以将由表单生成器加载一个自定义的widget插件时,被搜索的路径列表。

See also setPluginPath()和clearPluginPaths( ) 。

  1. QFormBuilder.clearPluginPaths (self)

清除表单生成器使用搜索自定义的widget插件路径的列表。

See also pluginPaths( ) 。

  1. list-of-QDesignerCustomWidgetInterface QFormBuilder.customWidgets (self)

返回的可用插件的列表。

  1. QStringList QFormBuilder.pluginPaths (self)

返回的路径表单生成器搜索插件列表中。

See also addPluginPath( ) 。

  1. QFormBuilder.setPluginPath (self, QStringList pluginPaths)

的插件路径列表中设置由指定的列表pluginPaths

See also addPluginPath( ) 。