2

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.

  • 1
    I had the exact same issue a few weeks ago, the answer in this post solved it: My plugins crashes with “No module named qgsprojectionselectionwidget” in Windows – Joseph Jun 28 '16 at 13:19
  • Did you replace the header of the QgsCollapsibleGroupBox class in your plugin.ui file from <header>qgsmaplayercombobox.h</header> to <header>qgis.gui</header>? – Joseph Jun 29 '16 at 8:48
  • 1
    Just did it. It works like a charm. The tiny problem is that I have to do the change again each time I touch my GUI. Qt Designer seems to be erasing this manual modification. But anyways, it does the trick thanks a lot ! – El Theo Jun 29 '16 at 9:05
  • Most welcome! Yes that is correct, which is why I keep my text editor open in my second monitor with the .ui file already loaded ;) – Joseph Jun 29 '16 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.