class 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#

Methods#

Virtual methods#

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

class 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.

__init__([parent=None[, flags={}]])#
Parameters:

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

aboutToUnmanageWidget(widget)#
Parameters:

widgetQWidget

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 absoluteDir()#
Return type:

QDir

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

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.

activated(widget)#
Parameters:

widgetQWidget

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

activeResourceFilePaths()#
Return type:

list of strings

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

abstract addResourceFile(path)#
Parameters:

path – str

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

abstract author()#
Return type:

str

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

See also

setAuthor()

abstract beginCommand(description)#
Parameters:

description – str

changed()#

This signal is emitted whenever a form is changed.

abstract 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 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 commandHistory()#
Return type:

QUndoStack

abstract comment()#
Return type:

str

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

See also

setComment()

abstract contents()#
Return type:

str

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

See also

setContents()

core()#
Return type:

QDesignerFormEditorInterface

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

abstract currentTool()#
Return type:

int

abstract editWidgets()#
abstract emitSelectionChanged()#

Emits the selectionChanged() signal.

abstract endCommand()#
abstract ensureUniqueObjectName(object)#
Parameters:

objectQObject

abstract 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

featureChanged(f)#
Parameters:

f – Combination of FeatureFlag

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

See also

setFeatures()

abstract features()#
Return type:

Combination of FeatureFlag

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 fileName()#
Return type:

str

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

See also

setFileName()

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 findFormWindow(obj)#
Parameters:

objQObject

Return type:

QDesignerFormWindowInterface

Returns the form window interface for the given object.

static findFormWindow(w)
Parameters:

wQWidget

Return type:

QDesignerFormWindowInterface

Returns the form window interface for the given widget.

abstract formContainer()#
Return type:

QWidget

Returns the form the widget containing the main container widget.

geometryChanged()#

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

abstract grid()#
Return type:

QPoint

Returns the grid spacing used by the form window.

See also

setGrid()

abstract hasFeature(f)#
Parameters:

f – Combination of FeatureFlag

Return type:

bool

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

See also

features()

abstract 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 isDirty()#
Return type:

bool

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

See also

setDirty()

abstract isManaged(widget)#
Parameters:

widgetQWidget

Return type:

bool

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

See also

manageWidget()

abstract 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 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 mainContainer()#
Return type:

QWidget

mainContainerChanged(mainContainer)#
Parameters:

mainContainerQWidget

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

abstract manageWidget(widget)#
Parameters:

widgetQWidget

Instructs the form window to manage the specified widget.

objectRemoved(o)#
Parameters:

oQObject

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 pixmapFunction()#
Return type:

str

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

abstract registerTool(tool)#
Parameters:

toolQDesignerFormWindowToolInterface

abstract removeResourceFile(path)#
Parameters:

path – str

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

abstract resourceFileSaveMode()#
Return type:

ResourceFileSaveMode

Returns the resource file save mode behavior.

abstract resourceFiles()#
Return type:

list of strings

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

resourceFilesChanged()#

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

See also

resourceFiles()

abstract selectWidget(w[, select=true])#
Parameters:

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

selectionChanged()#

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

abstract setAuthor(author)#
Parameters:

author – str

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

See also

author()

abstract 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 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 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 setCurrentTool(index)#
Parameters:

index – int

abstract 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 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 setFeatures(f)#
Parameters:

f – Combination of FeatureFlag

Enables the specified features for the form window.

abstract setFileName(fileName)#
Parameters:

fileName – str

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

abstract setGrid(grid)#
Parameters:

gridQPoint

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 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 setLayoutDefault(margin, spacing)#
Parameters:
  • margin – int

  • spacing – int

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

See also

layoutDefault()

abstract 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 setMainContainer(mainContainer)#
Parameters:

mainContainerQWidget

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

abstract setPixmapFunction(pixmapFunction)#
Parameters:

pixmapFunction – str

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

See also

pixmapFunction()

abstract setResourceFileSaveMode(behaviour)#
Parameters:

behaviourResourceFileSaveMode

Sets the resource file save mode behavior.

abstract simplifySelection(widgets)#
Parameters:

widgetsQList

abstract tool(index)#
Parameters:

index – int

Return type:

QDesignerFormWindowToolInterface

toolChanged(toolIndex)#
Parameters:

toolIndex – int

abstract toolCount()#
Return type:

int

abstract unmanageWidget(widget)#
Parameters:

widgetQWidget

Instructs the form window not to manage the specified widget.

widgetManaged(widget)#
Parameters:

widgetQWidget

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

See also

manageWidget()

widgetRemoved(w)#
Parameters:

wQWidget

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

widgetUnmanaged(widget)#
Parameters:

widgetQWidget

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