As far as I can tell, the reason Qt5 Designer does not load custom PyQt5 widgets
is due to the 'stock' shared library libpyqt5.so
(which comes with PyQt5) not
being built for the correct combination of the Python and Qt versions. It seems
the only way to get around this is to build PyQt5 from source so we will have a
libpyqt5.so
that is correct and will be able to load the custom widgets.
I don't know if this is necessary, I already had it installed
$ sudo apt-get install libpython3-dev
SIP is a Python/C++ bindings generator used to build the bindings for PyQt. PyQt5.11.3 needs SIP 4.19.13, so build from source.
$ wget https://sourceforge.net/projects/pyqt/files/sip/sip-4.19.13/sip-4.19.13.tar.gz
$ tar xzvf sip-4.19.13.tar.gz
$ cd sip-4.19.13
$ python3.9 configure.py
$ make -j4
$ sudo make install
On my system I have both Qt4 and Qt5 installed. But on stretch Qt4 is the default so we have to set up the environment to use Qt5 before trying to build PyQt5.
Make sure Qt5 is installed:
$ qtchooser -list-versions
Select the Qt version:
$ export QT_SELECT=qt5
Check qmake version:
$ qmake --version
This should say
QMake version 3.0
Using Qt version 5.15.2 in /usr/lib/x86_64-linux-gnu
$ wget https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.11.3/PyQt5_gpl-5.11.3.tar.gz
$ tar xzvf PyQt5_gpl-5.11.3.tar.gz
$ cd PyQt5_gpl-5.11.3
$ python3.9 configure.py
$ make -j4
$ sudo make install
Use the PYQTDESIGNERPATH
environment variable to tell QtDesiner where to look
for the plugins
$ export PYQTDESIGNERPATH='/path/to/plugin/directory/'
Launch Qt5 Designer
$ qtchooser -run-tool=designer -qt=5
https://gist.github.com/KurtJacobson/34a2e45ea2227ba58702fc1cb0372c40
https://www.ics.com/blog/integrating-python-based-custom-widget-qt-designer
https://harishnavnit.wordpress.com/2014/03/24/handling-multiple-versions-of-qt