Search code examples
pythonpyqtpyqt5qt-designerqt-signals

How to make signals appear in QtDesigner?


The PyQt5 docs says

"New signals defined in this way will be automatically added to the class’s QMetaObject. This means that they will appear in Qt Designer"

How do I make anything appear in QtDesigner if it only knows how to open *.ui files, but not python files?

In my workflow I create ui-file with QtDesigner, then convert it to python using pyuic5. It is thus a one-way conversion (I then subclass it in another file to avoid my code being overwritten).

How do I make QtDesigner "see" my python code?


Solution

  • Qt Designer recognizes 2 types of elements:

    • The .ui that are the product,

    • And the plugins that are the ingredients.

    So if you want a widget to be seen in Qt Designer you must create a plugin, if you download the source code in the folder examples/designer/plugins there is an example.

    On the other hand there is no converter from .py to .ui since the transformation is not possible in all cases.