QFormBuilder¶
The QFormBuilder
class is used to dynamically construct user interfaces from UI files at run-time. More…
Synopsis¶
Functions¶
def
addPluginPath
(pluginPath)def
clearPluginPaths
()def
customWidgets
()def
pluginPaths
()def
setPluginPath
(pluginPaths)
Virtual functions¶
def
updateCustomWidgets
()
Static functions¶
def
widgetByName
(topLevel, name)
Detailed Description¶
The QFormBuilder
class provides a mechanism for dynamically creating user interfaces at run-time, based on UI files created with Qt Designer. For example:
MyForm::MyForm(QWidget parent) QWidget.__init__(self, parent) builder = QFormBuilder() file = QFile(":/forms/myWidget.ui") file.open(QFile.ReadOnly) myWidget = builder.load(file, self) file.close() layout = 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:
<not 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:
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.
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 module.
See also
QAbstractFormBuilder
Qt UI Tools
- class PySide6.QtDesigner.QFormBuilder¶
Constructs a new form builder.
- PySide6.QtDesigner.QFormBuilder.addPluginPath(pluginPath)¶
- Parameters
pluginPath – str
Adds a new plugin path specified by pluginPath
to the list of paths that will be searched by the form builder when loading a custom widget plugin.
See also
- PySide6.QtDesigner.QFormBuilder.clearPluginPaths()¶
Clears the list of paths that the form builder uses to search for custom widget plugins.
See also
- PySide6.QtDesigner.QFormBuilder.customWidgets()¶
- Return type
Returns a list of the available plugins.
- PySide6.QtDesigner.QFormBuilder.pluginPaths()¶
- Return type
list of strings
Returns the list of paths the form builder searches for plugins.
See also
- PySide6.QtDesigner.QFormBuilder.setPluginPath(pluginPaths)¶
- Parameters
pluginPaths – list of strings
Sets the list of plugin paths to the list specified by pluginPaths
.
See also
- PySide6.QtDesigner.QFormBuilder.updateCustomWidgets()¶
- static PySide6.QtDesigner.QFormBuilder.widgetByName(topLevel, name)¶
- Parameters
topLevel –
PySide6.QtWidgets.QWidget
name – str
- Return type
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.