Qt Designer

PythonQwt ships a Qt Designer plugin which makes a 2D plotting widget (qwt.qtdesigner.QwtPlotWidget, a thin qwt.QwtPlot subclass) available directly inside Qt Designer’s widget box, in the “PythonQwt” group.

Installing the plugin

The plugin file qwtplugin.py lives in the qtdesigner directory at the root of the PythonQwt source tree. To make it available in Qt Designer, add that directory to the PYQTDESIGNERPATH environment variable before starting Qt Designer:

# Linux/macOS
export PYQTDESIGNERPATH=<path to PythonQwt>/qtdesigner
designer
rem Windows
set PYQTDESIGNERPATH=<path to PythonQwt>\qtdesigner
designer

Note

Qt Designer custom widget plugins require PyQt5 or PyQt6. PySide6 does not expose QPyDesignerCustomWidgetPlugin.

Loading a .ui file at runtime

The qwt.qtdesigner module provides helper functions to load or compile .ui files embedding qwt.qtdesigner.QwtPlotWidget widgets:

from qwt.qtdesigner import loadui

FormClass = loadui("myform.ui")
form = FormClass()
form.plotwidget.setTitle("Loaded from Qt Designer")

Reference

Qt Designer

The qwt.qtdesigner module provides helpers to integrate qwt widgets into Qt Designer:

QwtPlotWidget is a thin qwt.QwtPlot subclass exposing the standard Qt widget constructor (__init__(self, parent=None)). It is the widget promoted by the Qt Designer plugin, so that the code generated by uic (e.g. QwtPlotWidget(parent=...) with PyQt6) instantiates it correctly. qwt.QwtPlot itself keeps its historical constructor.

Note

Qt Designer custom widget plugins rely on QtDesigner.QPyDesignerCustomWidgetPlugin, which is only available with PyQt5/PyQt6. PySide6 does not expose this class.

class qwt.qtdesigner.QwtPlotWidget(parent=None)[source]

qwt.QwtPlot widget with the standard Qt constructor.

This subclass is meant to be promoted in Qt Designer: unlike qwt.QwtPlot (whose constructor accepts the historical QwtPlot([title], [parent]) overloads), it exposes the conventional __init__(self, parent=None) signature expected by the code generated by uic (notably PyQt6, which uses QwtPlotWidget(parent=...)).

Args:

parent: Parent widget

qwt.qtdesigner.loadui(fname: str, replace_class: str | None = None)[source]

Return Widget or Window class from a Qt Designer .ui file.

When a promoted widget inherits from a class that is not known to the uic parser (i.e. not a standard Qt widget), loadUiType fails to resolve the widget hierarchy. Passing the offending base class name as replace_class neutralizes it by substituting QFrame (the base class of qwt.QwtPlot) before the file is parsed.

For a plain qwt.QwtPlot widget (which already inherits from QFrame), no replacement is required and replace_class can be left to None.

Args:

fname: Path to the .ui file replace_class: Base class name to replace by QFrame, or None

to load the file unchanged

Returns:

The generated form class

qwt.qtdesigner.compileui(fname: str, replace_class: str | None = None) None[source]

Compile a Qt Designer .ui file into a Python module.

Args:

fname: Path to the .ui file replace_class: Base class name to replace by QFrame, or None

to compile the file unchanged

qwt.qtdesigner.create_qtdesigner_plugin(group: str, module_name: str, class_name: str, icon: str | QIcon | None = None, tooltip: str = '', whatsthis: str = '')[source]

Return a custom Qt Designer plugin class.

Args:

group: Name of the group the widget belongs to in Qt Designer module_name: Name of the module where the widget class is defined class_name: Name of the widget class icon: Icon shown in Qt Designer (path to an image file or

QtGui.QIcon instance)

tooltip: Tool tip shown in Qt Designer whatsthis: “What’s this” help text shown in Qt Designer

Returns:

A QtDesigner.QPyDesignerCustomWidgetPlugin subclass

Example:

Plugin = create_qtdesigner_plugin(
    group="PythonQwt",
    module_name="qwt.qtdesigner",
    class_name="QwtPlotWidget",
)