In Qt Designer the extensions are not created until they are required. For that reason, when implementing an extension, you must also create a
QExtensionFactory , i.e a class that is able to make an instance of your extension, and register it using Qt Designer's extension manager.
The registration of an extension factory is typically made in the
def initialize(self, formEditor): if (initialized) return manager = formEditor.extensionManager() Q_ASSERT(manager != 0) manager.registerExtensions(MyExtensionFactory(manager), Q_TYPEID(QDesignerTaskMenuExtension)) initialized = True
QExtensionManager is not intended to be instantiated directly. You can retrieve an interface to Qt Designer's extension manager using the
extensionManager() function. A 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 to expose your plugin to Qt Designer.
Then, when an extension is required, Qt Designer's extension manager will run through all its registered factories calling
createExtension() for each until the first one that is able to create the requested extension for the selected object, is found. This factory will then make an instance of the extension.
There are four available types of extensions in Qt Designer:
QDesignerTaskMenuExtension . Qt Designer's behavior is the same whether the requested extension is associated with a container, a member sheet, a property sheet or a task menu.
For a complete example using the
QExtensionManager class, see the Task Menu Extension example . The example shows how to create a custom widget plugin for Qt Designer, and how to to use the
QDesignerTaskMenuExtension class to add custom items to Qt Designer's task menu.
- class PySide6.QtDesigner.QExtensionManager([parent=None])¶
Constructs an extension manager with the given
© 2021 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.