QDesignerFormWindowInterface#

The QDesignerFormWindowInterface class allows you to query and manipulate form windows appearing in Qt Designer’s workspace. More

Inheritance diagram of PySide6.QtDesigner.QDesignerFormWindowInterface

Synopsis#

Functions#

Virtual functions#

Slots#

Signals#

Static functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

Warning

This section contains snippets that were automatically translated from C++ to Python and may contain errors.

QDesignerFormWindowInterface provides information about the associated form window as well as allowing its properties to be altered. The interface is not intended to be instantiated directly, but to provide access to Qt Designer's current form windows controlled by Qt Designer's form window manager .

If you are looking for the form window containing a specific widget, you can use the static findFormWindow() function:

formWindow = QDesignerFormWindowInterface.findFormWindow(myWidget)

But in addition, you can access any of the current form windows through Qt Designer's form window manager: Use the formWindowManager() function to retrieve an interface to the manager. Once you have this interface, you have access to all of Qt Designer's current form windows through the formWindow() function. For example:

*> = QList<QDesignerFormWindowInterface()
    manager = formEditor.formWindowManager()
    for i in range(0, manager.formWindowCount()):
        forms.append(manager.formWindow(i))

The pointer to Qt Designer's current QDesignerFormEditorInterface object (formEditor in the example above) is provided by the initialize() function’s parameter. When implementing a custom widget plugin, you must subclass the QDesignerCustomWidgetInterface class to expose your plugin to Qt Designer.

Once you have the form window, you can query its properties. For example, a plain custom widget plugin is managed by Qt Designer only at its top level, i.e. none of its child widgets can be resized in Qt Designer's workspace. But QDesignerFormWindowInterface provides you with functions that enables you to control whether a widget should be managed by Qt Designer, or not:

if formWindow.isManaged(myWidget):
    formWindow.manageWidget(myWidget.childWidget)

The complete list of functions concerning widget management is: isManaged() , manageWidget() and unmanageWidget() . There is also several associated signals: widgetManaged() , widgetRemoved() , aboutToUnmanageWidget() and widgetUnmanaged() .

In addition to controlling the management of widgets, you can control the current selection in the form window using the selectWidget() , clearSelection() and emitSelectionChanged() functions, and the selectionChanged() signal.

You can also retrieve information about where the form is stored using absoluteDir() , its include files using includeHints() , and its layout and pixmap functions using layoutDefault() , layoutFunction() and pixmapFunction() . You can find out whether the form window has been modified (but not saved) or not, using the isDirty() function. You can retrieve its author() , its contents() , its fileName() , associated comment() and exportMacro() , its mainContainer(), its features() , its grid() and its resourceFiles() .

The interface provides you with functions and slots allowing you to alter most of this information as well. The exception is the directory storing the form window. Finally, there is several signals associated with changes to the information mentioned above and to the form window in general.

class PySide6.QtDesigner.QDesignerFormWindowInterface([parent=None[, flags={}]])#
Parameters:

Constructs a form window interface with the given parent and the specified window flags.

PySide6.QtDesigner.QDesignerFormWindowInterface.FeatureFlag#

(inherits enum.Flag) This enum describes the features that are available and can be controlled by the form window interface. These values are used when querying the form window to determine which features it supports:

Constant

Description

QDesignerFormWindowInterface.EditFeature

Form editing

QDesignerFormWindowInterface.GridFeature

Grid display and snap-to-grid facilities for editing

QDesignerFormWindowInterface.TabOrderFeature

Tab order management

QDesignerFormWindowInterface.DefaultFeature

Support for default features (form editing and grid)

PySide6.QtDesigner.QDesignerFormWindowInterface.ResourceFileSaveMode#

This enum describes how resource files are saved.

Constant

Description

QDesignerFormWindowInterface.SaveAllResourceFiles

Save all resource files.

QDesignerFormWindowInterface.SaveOnlyUsedResourceFiles

Save resource files used by form.

QDesignerFormWindowInterface.DontSaveResourceFiles

Do not save resource files.

PySide6.QtDesigner.QDesignerFormWindowInterface.aboutToUnmanageWidget(widget)#
Parameters:

widgetPySide6.QtWidgets.QWidget

This signal is emitted whenever a widget on the form is about to become unmanaged. When this signal is emitted, the specified widget is still managed, and a widgetUnmanaged() signal will follow, indicating when it is no longer managed.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.absoluteDir()#
Return type:

PySide6.QtCore.QDir

Returns the absolute location of the directory containing the form shown in the form window.

PySide6.QtDesigner.QDesignerFormWindowInterface.activateResourceFilePaths(paths[, errorCount=None[, errorMessages=None]])#
Parameters:
  • paths – list of strings

  • errorCount – int

  • errorMessages – str

Activates the resource (.qrc) file paths paths, returning the count of errors in errorCount and error message in errorMessages. Qt Designer loads the resources using the QResource class, making them available for form editing.

In IDE integrations, a list of the project’s resource (.qrc) file can be activated, making them available to Qt Designer.

See also

activeResourceFilePaths() QResource

PySide6.QtDesigner.QDesignerFormWindowInterface.activated(widget)#
Parameters:

widgetPySide6.QtWidgets.QWidget

This signal is emitted whenever a widget is activated on the form. The activated widget is specified by widget.

PySide6.QtDesigner.QDesignerFormWindowInterface.activeResourceFilePaths()#
Return type:

list of strings

Returns the active resource (.qrc) file paths currently loaded in Qt Designer.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.addResourceFile(path)#
Parameters:

path – str

Adds the resource file at the given path to those used by the form.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.author()#
Return type:

str

Returns details of the author or creator of the form currently being displayed in the window.

See also

setAuthor()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.beginCommand(description)#
Parameters:

description – str

PySide6.QtDesigner.QDesignerFormWindowInterface.changed()#

This signal is emitted whenever a form is changed.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.checkContents()#
Return type:

list of strings

Performs checks on the current form and returns a list of richtext warnings about potential issues (for example, top level spacers on unlaid-out forms).

IDE integrations can call this before handling starting a save operation.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.clearSelection([changePropertyDisplay=true])#
Parameters:

changePropertyDisplay – bool

Clears the current selection in the form window. If update is true, the emitSelectionChanged() function is called, emitting the selectionChanged() signal.

See also

selectWidget()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.commandHistory()#
Return type:

PySide6.QtGui.QUndoStack

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.comment()#
Return type:

str

Returns comments about the form currently being displayed in the window.

See also

setComment()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.contents()#
Return type:

str

Returns details of the contents of the form currently being displayed in the window.

See also

setContents()

PySide6.QtDesigner.QDesignerFormWindowInterface.core()#
Return type:

PySide6.QtDesigner.QDesignerFormEditorInterface

Returns a pointer to Qt Designer's current QDesignerFormEditorInterface object.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.currentTool()#
Return type:

int

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.editWidgets()#
abstract PySide6.QtDesigner.QDesignerFormWindowInterface.emitSelectionChanged()#

Emits the selectionChanged() signal.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.endCommand()#
abstract PySide6.QtDesigner.QDesignerFormWindowInterface.ensureUniqueObjectName(object)#
Parameters:

objectPySide6.QtCore.QObject

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.exportMacro()#
Return type:

str

Returns the export macro associated with the form currently being displayed in the window. The export macro is used when the form is compiled to create a widget plugin.

See also

setExportMacro() Creating Custom Widgets for Qt Designer

PySide6.QtDesigner.QDesignerFormWindowInterface.featureChanged(f)#
Parameters:

fFeature

This signal is emitted whenever a feature changes in the form. The new feature is specified by feature.

See also

setFeatures()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.features()#
Return type:

Feature

Returns a combination of the features provided by the form window associated with the interface. The value returned can be tested against the Feature enum values to determine which features are supported by the window.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.fileName()#
Return type:

str

Returns the file name of the UI file that describes the form currently being shown.

See also

setFileName()

PySide6.QtDesigner.QDesignerFormWindowInterface.fileNameChanged(fileName)#
Parameters:

fileName – str

This signal is emitted whenever the file name of the form changes. The new file name is specified by fileName.

See also

setFileName()

static PySide6.QtDesigner.QDesignerFormWindowInterface.findFormWindow(obj)#
Parameters:

objPySide6.QtCore.QObject

Return type:

PySide6.QtDesigner.QDesignerFormWindowInterface

Returns the form window interface for the given object.

static PySide6.QtDesigner.QDesignerFormWindowInterface.findFormWindow(w)
Parameters:

wPySide6.QtWidgets.QWidget

Return type:

PySide6.QtDesigner.QDesignerFormWindowInterface

Returns the form window interface for the given widget.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.formContainer()#
Return type:

PySide6.QtWidgets.QWidget

Returns the form the widget containing the main container widget.

PySide6.QtDesigner.QDesignerFormWindowInterface.geometryChanged()#

This signal is emitted whenever the form’s geometry changes.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.grid()#
Return type:

PySide6.QtCore.QPoint

Returns the grid spacing used by the form window.

See also

setGrid()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.hasFeature(f)#
Parameters:

fFeature

Return type:

bool

Returns true if the form window offers the specified feature; otherwise returns false.

See also

features()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.includeHints()#
Return type:

list of strings

Returns a list of the header files that will be included in the form window’s associated UI file.

Header files may be local, i.e. relative to the project’s directory, "mywidget.h", or global, i.e. part of Qt or the compilers standard libraries: <QtGui/QWidget>.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.isDirty()#
Return type:

bool

Returns true if the form window is “dirty” (modified but not saved); otherwise returns false.

See also

setDirty()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.isManaged(widget)#
Parameters:

widgetPySide6.QtWidgets.QWidget

Return type:

bool

Returns true if the specified widget is managed by the form window; otherwise returns false.

See also

manageWidget()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.layoutDefault(margin, spacing)#
Parameters:
  • margin – int

  • spacing – int

Fills in the default margin and spacing for the form’s default layout in the margin and spacing variables specified.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.layoutFunction(margin, spacing)#
Parameters:
  • margin – str

  • spacing – str

Fills in the current margin and spacing for the form’s layout in the margin and spacing variables specified.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.mainContainer()#
Return type:

PySide6.QtWidgets.QWidget

PySide6.QtDesigner.QDesignerFormWindowInterface.mainContainerChanged(mainContainer)#
Parameters:

mainContainerPySide6.QtWidgets.QWidget

This signal is emitted whenever the main container changes. The new container is specified by mainContainer.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.manageWidget(widget)#
Parameters:

widgetPySide6.QtWidgets.QWidget

Instructs the form window to manage the specified widget.

PySide6.QtDesigner.QDesignerFormWindowInterface.objectRemoved(o)#
Parameters:

oPySide6.QtCore.QObject

This signal is emitted whenever an object (such as an action or a QButtonGroup ) is removed from the form. The object that was removed is specified by object.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.pixmapFunction()#
Return type:

str

Returns the name of the function used to load pixmaps into the form window.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.registerTool(tool)#
Parameters:

toolPySide6.QtDesigner.QDesignerFormWindowToolInterface

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.removeResourceFile(path)#
Parameters:

path – str

Removes the resource file at the specified path from the list of those used by the form.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.resourceFileSaveMode()#
Return type:

ResourceFileSaveMode

Returns the resource file save mode behavior.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.resourceFiles()#
Return type:

list of strings

Returns a list of paths to resource files that are currently being used by the form window.

PySide6.QtDesigner.QDesignerFormWindowInterface.resourceFilesChanged()#

This signal is emitted whenever the list of resource files used by the form changes.

See also

resourceFiles()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.selectWidget(w[, select=true])#
Parameters:

If select is true, the given widget is selected; otherwise the widget is deselected.

PySide6.QtDesigner.QDesignerFormWindowInterface.selectionChanged()#

This signal is emitted whenever the selection in the form changes.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setAuthor(author)#
Parameters:

author – str

Sets the details for the author or creator of the form to the author specified.

See also

author()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setComment(comment)#
Parameters:

comment – str

Sets the information about the form to the comment specified. This information should be a human-readable comment about the form.

See also

comment()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setContents(dev[, errorMessage=None])#
Parameters:
Return type:

bool

Sets the form’s contents using data obtained from the given device and returns whether loading succeeded. If it fails, the error message is returned in errorMessage.

Data can be read from QFile objects or any other subclass of QIODevice .

See also

contents()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setContents(contents)
Parameters:

contents – str

Return type:

bool

Sets the contents of the form using data read from the specified contents string and returns whether the operation succeeded.

See also

contents()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setCurrentTool(index)#
Parameters:

index – int

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setDirty(dirty)#
Parameters:

dirty – bool

If dirty is true, the form window is marked as dirty, meaning that it is modified but not saved. If dirty is false, the form window is considered to be unmodified.

See also

isDirty()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setExportMacro(exportMacro)#
Parameters:

exportMacro – str

Sets the form window’s export macro to exportMacro. The export macro is used when building a widget plugin to export the form’s interface to other components.

See also

exportMacro()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setFeatures(f)#
Parameters:

fFeature

Enables the specified features for the form window.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setFileName(fileName)#
Parameters:

fileName – str

Sets the file name for the form to the given fileName.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setGrid(grid)#
Parameters:

gridPySide6.QtCore.QPoint

Sets the grid size for the form window to the point specified by grid. In this function, the coordinates in the QPoint are used to specify the dimensions of a rectangle in the grid.

See also

grid()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setIncludeHints(includeHints)#
Parameters:

includeHints – list of strings

Sets the header files that will be included in the form window’s associated UI file to the specified includeHints.

Header files may be local, i.e. relative to the project’s directory, "mywidget.h", or global, i.e. part of Qt or the compilers standard libraries: <QtGui/QWidget>.

See also

includeHints()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setLayoutDefault(margin, spacing)#
Parameters:
  • margin – int

  • spacing – int

Sets the default margin and spacing for the form’s layout.

See also

layoutDefault()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setLayoutFunction(margin, spacing)#
Parameters:
  • margin – str

  • spacing – str

Sets the margin and spacing for the form’s layout.

The default layout properties will be replaced by the corresponding layout functions when uic generates code for the form, that is, if the functions are specified. This is useful when different environments requires different layouts for the same form.

See also

layoutFunction()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setMainContainer(mainContainer)#
Parameters:

mainContainerPySide6.QtWidgets.QWidget

Sets the main container widget on the form to the specified mainContainer.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setPixmapFunction(pixmapFunction)#
Parameters:

pixmapFunction – str

Sets the function used to load pixmaps into the form window to the given pixmapFunction.

See also

pixmapFunction()

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.setResourceFileSaveMode(behaviour)#
Parameters:

behaviourResourceFileSaveMode

Sets the resource file save mode behavior.

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.simplifySelection(widgets)#
Parameters:

widgetsQList

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.tool(index)#
Parameters:

index – int

Return type:

PySide6.QtDesigner.QDesignerFormWindowToolInterface

PySide6.QtDesigner.QDesignerFormWindowInterface.toolChanged(toolIndex)#
Parameters:

toolIndex – int

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.toolCount()#
Return type:

int

abstract PySide6.QtDesigner.QDesignerFormWindowInterface.unmanageWidget(widget)#
Parameters:

widgetPySide6.QtWidgets.QWidget

Instructs the form window not to manage the specified widget.

PySide6.QtDesigner.QDesignerFormWindowInterface.widgetManaged(widget)#
Parameters:

widgetPySide6.QtWidgets.QWidget

This signal is emitted whenever a widget on the form becomes managed. The newly managed widget is specified by widget.

See also

manageWidget()

PySide6.QtDesigner.QDesignerFormWindowInterface.widgetRemoved(w)#
Parameters:

wPySide6.QtWidgets.QWidget

This signal is emitted whenever a widget is removed from the form. The widget that was removed is specified by widget.

PySide6.QtDesigner.QDesignerFormWindowInterface.widgetUnmanaged(widget)#
Parameters:

widgetPySide6.QtWidgets.QWidget

This signal is emitted whenever a widget on the form becomes unmanaged. The newly released widget is specified by widget.