Qt Designer: could not find custom PyQt widget plugins

≡放荡痞女 提交于 2020-02-23 07:04:59

问题


I wrote a lot of custom widget plug-ins for using them in the Qt Designer and my Pipeline.

This is working fine on my Mac (Mavericks, PyQt4, Python 2.7), and this week I wanted to implement those plugins on my Windows environment as well. But it wasn't working. The plug-ins are not appear in the Qt Designer's Widget Box on the left (Windows 7, PyQt4, Python 2.7).

After a lot of try's, I downloaded the PyQt4 example files and followed the instructions from: PyQt Reference Guide and also the instructions from the example launcher file examples/designer/plugins/plugins.py itself, but it was still not working.

So I copied the the following example files:

  • plugin files to "C:\designer_plugins"
  • widget files to "C:\designer_widgets"

Just to making the code as simple as possible to figure out what is going wrong.

So, this is my testing plugins.py file:

#!/usr/bin/env python
import sys
import os

from PyQt4 import QtCore, QtGui, uic

env = os.environ.copy()

env['PYTHONPATH']       = r"C:\designer_widgets" #("%s"%os.pathsep).join(sys.path)
env['PYQTDESIGNERPATH'] = r"C:\designer_plugins"

qenv = ['%s="%s"' % (name, value) for name, value in env.items()]

# Start Designer.
designer = QtCore.QProcess()
designer.setEnvironment(qenv)

designer_bin = r"C:\Python27x64\Lib\site-packages\PyQt4\designer.exe"

designer.start(designer_bin)
designer.waitForFinished(-1)

sys.exit(designer.exitCode())

I thought that my designer object didn't get the right path, so I implemented the folowing to check it's environment:

# Check if paths are right
print "\n # Designer Env:"
for pypath in designer.environment():
    if "PYTHONPATH" in pypath:
        print " #  ",pypath
    if "PYQTDESIGNERPATH" in pypath:
        print " #  ",pypath

Console output:

 # Designer Env:
 #   PYQTDESIGNERPATH="C:\designer_plug"
 #   PYTHONPATH="C:\designer_widgets"

The paths are right. And like I said, on my mac it works perfectly. I was trying this also with different Qt Designer installations. But both (PyQt4 and PySide) designers doesn't show any of the example plugins. Both Qt Designer couldn't find the example plugins. I double checked it inside the designer with Help/About Plugins).

Any ideas what I did wrong? Or is this generally not working on a Windows 7 System?


回答1:


All fixed. I rebuild PyQt4, so I think I made probably a mistake in the source code of Qt in the past.



来源:https://stackoverflow.com/questions/28068283/qt-designer-could-not-find-custom-pyqt-widget-plugins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!