I'm building a QGIS plugin, and I am making the GUI using Qt Designer.
Whenever I am using one of the "QGIS custom widgets" (in the present case, a QgsCollapsibleGroupBox) in my plugin window, it doesn't work anymore. If it's a new plugin and isn't installed yet, it is flagged as corrupted, with the error "No module named qgscollapsiblegroupbox". And if I modify the GUI of an existing plugin, I got the same error but with a bit more details :
Traceback (most recent call last):
File "C:/OSGEO4~1/apps/qgis-ltr/./python\qgis\utils.py", line 219, in startPlugin plugins[packageName] = package.classFactory(iface)
File "C:/Users/eltheo/.qgis2/python/plugins\myplugin__init__.py", line 34, in classFactory from .myplugin import myplugin
File "C:/OSGEO4~1/apps/qgis-ltr/./python\qgis\utils.py", line 478, in _import mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/eltheo/.qgis2/python/plugins\myplugin\myplugin.py", line 31, in from list_dockwidget import listDockWidget
File "C:/OSGEO4~1/apps/qgis-ltr/./python\qgis\utils.py", line 478, in _import mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/eltheo/.qgis2/python/plugins\myplugin\myplugin_dockwidget.py", line 30, in os.path.dirname(file), 'myplugin_dockwidget_base.ui'))
File "C:\OSGEO4~1\apps\Python27\lib\site-packages\PyQt4\uic__init__.py", line 213, in loadUiType exec(code_string.getvalue(), ui_globals)
File "", line 205, in
File "C:/OSGEO4~1/apps/qgis-ltr/./python\qgis\utils.py", line 478, in _import mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named qgscollapsiblegroupbox
I had the same problem a couple weeks ago with a QgsFieldComboBox, so I guess the problem lies with all the QGIS custom widgets.
I've looked in the ui_myplugin.py file that it generated when the plugin is compilated, I've found a line at the very end, that seems to be the problem :
from qgscollapsiblegroupbox import QgsCollapsibleGroupBox
I've try to put that line at the begining of the code with the other import, then to replace it with
from qgis.gui import QgsCollapsibleGroupBox / from qgis.gui import *
But nothing changes, which is odd for the error should at least be different as there is no more mention of "qgscollapsiblegroupbox" in my files.
QgsCollapsibleGroupBoxclass in your plugin.ui file from<header>qgsmaplayercombobox.h</header>to<header>qgis.gui</header>? – Joseph Jun 29 '16 at 08:48