Search code examples
qtpyqtpyqt5qt-designer

Custom PyQt5 widgets Qt Designer


I have been trying (without success) to get Custom PyQt5 widgets to show up in Qt Designer for a couple of days now.

Some information: Window, Python 3.9.1, Pyqt5.15.6, Qt Designer 5.11.1

I have downloaded the source code for PyQt5-5.15.6 here, and I am trying to run the example under: PyQt5-5.15.6\examples\designer\plugins

Qt Designer does launch, but no additional widgets appear in the menu. Under help > plugin information it says: "Failed to extract plugin meta data from 'C:/Program Files (x86)/Qt Designer/plugins/designer/pyqt5.dll". Could this be why the widget imports are not working as expected?


Solution

  • For anyone having the same problem: I was using a standalone version of qt designer downloaded from here which does not seem to support custom python widgets.

    I eventually ended up using the qt designer installed by PySide6 (by installing PySide6 then running pyside6-designer from command line). The custom widgets can then be added by creating a widget_register.py file for each custom widget using the registerCustomWidget method.

    Be sure to then have the folder with the widget_register.py file(s) in your environment variables (PYSIDE_DESIGNER_PLUGINS=C:\...\your_registrar_folder) when starting Qt-Designer by either launching PySide6-designer from a script that first adds this variable to the environment each time or by manually adding the registrar folder to the system environment variables.