RIKEN IAD
RIKEN IAD

Reputation: 51

Can't get custom PyQt5 widget plugin to show up in Qt designer (macos)

I would like to make a custom widget plugin for Qt Designer using python (3.7 with pyqt5). Everything should work, but it doesn't show up in Qt Designer.

Here is what I have done so far after much trial and error and a little help from others with similar issues (Qt Designer: could not find custom PyQt widget plugins and Custom QWidgets. How do I build/get the pyqt5 plugin for Qt Designer on Mac?)

from PyQt5.QtCore import QLibraryInfo, QProcess, QProcessEnvironment


# Tell Qt Designer where it can find the directory containing the plugins and
# Python where it can find the widgets.
env = QProcessEnvironment.systemEnvironment()
env.insert('PYQTDESIGNERPATH', '[path to the plugin.py files]/designer_plugins')
env.insert('PYTHONPATH', '[path to the widgets]/designer_widgets')

# Start Designer.
designer = QProcess()
designer.setProcessEnvironment(env)
designer_bin = QLibraryInfo.location(QLibraryInfo.BinariesPath)

designer_bin = '/Users/[user]/Qt/5.13.0/clang_64/bin/Designer.app/Contents/MacOS/Designer'

designer.start(designer_bin)
designer.waitForFinished(-1)
[user]$ export QT_DEBUG_PLUGINS=1
[user]$ export PYQTDESIGNERPATH='[path to the widgets]/designer_widgets'
[user]$ export PYTHONPATH='[path to the widgets]/designer_widgets'

[user]$ /Users/[user]/Qt/5.13.0/clang_64/bin/Designer.app/Contents/MacOS/Designer

The relevant portion of the output was this:

Found metadata in lib /Users/[user]/Qt/5.13.0/clang_64/plugins/designer/libpyqt5.dylib, metadata=
{
    "IID": "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface",
    "archreq": 0,
    "className": "PyCustomWidgets",
    "debug": false,
    "version": 331008
}


loaded library "/Users/[user]/Qt/5.13.0/clang_64/plugins/designer/libpyqt5.dylib"

and toward the end

loaded library "Python.framework/Versions/3.7/Python"
ModuleNotFoundError: No module named 'PyQt5'
ModuleNotFoundError: No module named 'PyQt5'

In any case, that is my current state. I do not understand why the PyQt5 module cannot be found by Qt Designer or what else I can try to get this to work.

Upvotes: 1

Views: 1414

Answers (1)

RIKEN IAD
RIKEN IAD

Reputation: 51

here is an 🤦‍♂️ momemt So, I found this on the PyQt reference guide which I had somehow overlooked

  • For a simple but complete and fully documented example of a custom widget that defines new Qt signals, slots and properties, and its plugin, look in the examples/designer/plugins directory of the PyQt5 source package

ok. did that. ran the demo. it works fine. Copied the whole plugins directory somewhere else. still fine. So I must have done something funky naming the folders or something. anyway, now I will just work on making my own plugin. days of frustration because of being dumb. but happy it works.

Upvotes: 1

Related Questions