PySide6.QtDesigner.QDesignerWidgetBoxInterface

class QDesignerWidgetBoxInterface

The QDesignerWidgetBoxInterface class allows you to control the contents of Qt Widgets Designer’s widget box. More_

Inheritance diagram of PySide6.QtDesigner.QDesignerWidgetBoxInterface

Synopsis

Methods

Virtual methods

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.

QDesignerWidgetBoxInterface contains a collection of functions that is typically used to manipulate the contents of Qt Widgets Designer’s widget box.

Qt Widgets Designer uses an XML file to populate its widget box. The name of that file is one of the widget box’s properties, and you can retrieve it using the fileName() function.

QDesignerWidgetBoxInterface also provides the save() function that saves the contents of the widget box in the file specified by the widget box’s file name property. If you have made changes to the widget box, for example by dropping a widget into the widget box, without calling the save() function, the original content can be restored by a simple invocation of the load() function:

widgetBox = formEditor.widgetBox()
widgetBox.load()

The QDesignerWidgetBoxInterface class is not intended to be instantiated directly. You can retrieve an interface to Qt Designer’s widget box using the widgetBox() function. A pointer to Qt Widgets 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 to expose your plugin to Qt Widgets Designer.

If you want to save your changes, and at the same time preserve the original contents, you can use the save() function combined with the setFileName() function to save your changes into another file. Remember to store the name of the original file first:

originalFile = widgetBox.fileName()
widgetBox.setFileName("myWidgetBox.xml")
widgetBox.save()

Then you can restore the original contents of the widget box by resetting the file name to the original file and calling load() :

widgetBox.setFileName(originalFile)
widgetBox.load()

In a similar way, you can later use your customized XML file:

if widgetBox.filename() != "myWidgetBox.xml":
    widgetBox.setFileName("myWidgetBox.xml")
    widgetBox.load()
__init__([parent=None[, flags=Qt.WindowFlags()]])
Parameters:

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

abstract addCategory(cat)
Parameters:

catCategory

abstract addWidget(cat_idx, wgt)
Parameters:
  • cat_idx – int

  • wgtWidget

abstract category(cat_idx)
Parameters:

cat_idx – int

Return type:

Category

abstract categoryCount()
Return type:

int

abstract dropWidgets(item_list, global_mouse_pos)
Parameters:
  • item_list – .list of QDesignerDnDItemInterface

  • global_mouse_posQPoint

abstract fileName()
Return type:

str

Returns the name of the XML file Qt Widgets Designer is currently using to populate its widget box.

See also

setFileName()

findOrInsertCategory(categoryName)
Parameters:

categoryName – str

Return type:

int

abstract load()
Return type:

bool

Populates Qt Widgets Designer’s widget box by loading (or reloading) the currently specified XML file. Returns true if the file is successfully loaded; otherwise false.

See also

setFileName()

abstract removeCategory(cat_idx)
Parameters:

cat_idx – int

abstract removeWidget(cat_idx, wgt_idx)
Parameters:
  • cat_idx – int

  • wgt_idx – int

abstract save()
Return type:

bool

Saves the contents of Qt Widgets Designer’s widget box in the file specified by the fileName() function. Returns true if the content is successfully saved; otherwise false.

abstract setFileName(file_name)
Parameters:

file_name – str

Sets the XML file that Qt Widgets Designer will use to populate its widget box, to fileName. You must call load() to update the widget box with the new XML file.

See also

fileName() load()

abstract widget(cat_idx, wgt_idx)
Parameters:
  • cat_idx – int

  • wgt_idx – int

Return type:

Widget

abstract widgetCount(cat_idx)
Parameters:

cat_idx – int

Return type:

int

class Widget

Synopsis

Methods

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

class Type
__init__(w)
Parameters:

wWidget

__init__([aname=""[, xml=""[, icon_name=""[, atype=QDesignerWidgetBoxInterface.Widget.Type.Default]]]])
Parameters:
  • aname – str

  • xml – str

  • icon_name – str

  • atypeType

domXml()
Return type:

str

iconName()
Return type:

str

isNull()
Return type:

bool

name()
Return type:

str

setDomXml(xml)
Parameters:

xml – str

setIconName(icon_name)
Parameters:

icon_name – str

setName(aname)
Parameters:

aname – str

setType(atype)
Parameters:

atypeType

type()
Return type:

Type

class Category

Synopsis

Methods

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

class Type
__init__([aname=""[, atype=QDesignerWidgetBoxInterface.Category.Type.Default]])
Parameters:
  • aname – str

  • atypeType

addWidget(awidget)
Parameters:

awidgetWidget

isNull()
Return type:

bool

name()
Return type:

str

removeWidget(idx)
Parameters:

idx – int

setName(aname)
Parameters:

aname – str

setType(atype)
Parameters:

atypeType

type()
Return type:

Type

widget(idx)
Parameters:

idx – int

Return type:

Widget

widgetCount()
Return type:

int