[Qgis-developer] Problem with using QGIS custom widgets in plugin

Lauri Kajan lauri.kajan at gmail.com
Mon Nov 16 10:48:17 PST 2015


This was discussed earlier on the list
http://osgeo-org.1560.x6.nabble.com/Compiling-ui-files-with-custom-widgets-creates-wrong-imports-td5218684.html
Here's the bug report http://hub.qgis.org/issues/13428

This happens because PyQt is not aware of qgis_customwidgets.py located in
qgis\python\PyQt4\uic\widget-plugins folder.


-Lauri

On Mon, Nov 16, 2015 at 12:05 PM, enricofer <enricofer at gmail.com> wrote:

> I got a similar issue using QgsFieldExpressionWidget.
> After compiling ui with pyuic4 I found that the import statement at the
> end of the compiled .py was wrong. So I manually changed it to:
> from qgis.gui import QgsFieldExpressionWidget
>
> Regards
>
> Enrico Ferreguti
>
> 2015-11-16 10:30 GMT+01:00 Alexander Bruy [via OSGeo.org] <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5236568&i=0>>:
>
>> Hi all,
>>
>> I use QGIS custom widgets in my plugin, namely QgsMaplayerComboBox.
>> When I run QGIS under Linux all works fine, but under Windows I got
>> Python
>> error on startup related to missed enum entries:
>>
>>    File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\__init__.py",
>> line 210, in loadUiType
>>     winfo = compiler.UICompiler().compileUi(uifile, code_string,
>> from_imports, resource_suffix)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\Compiler\compiler.py",
>>
>> line 139, in compileUi
>>     w = self.parse(input_stream, resource_suffix)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
>> line 992, in parse
>>     actor(elem)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
>> line 818, in createUserInterface
>>     self.traverseWidgetTree(elem)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
>> line 796, in traverseWidgetTree
>>     handler(self, child)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
>> line 507, in createLayout
>>     self.traverseWidgetTree(elem)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
>> line 796, in traverseWidgetTree
>>     handler(self, child)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
>> line 550, in handleItem
>>     self.traverseWidgetTree(elem)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
>> line 796, in traverseWidgetTree
>>     handler(self, child)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
>> line 258, in createWidget
>>     self.stack.push(self.setupObject(widget_class, parent, elem))
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
>> line 220, in setupObject
>>     self.wprops.setProperties(obj, branch)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
>> line 418, in setProperties
>>     prop_value = self.convert(prop, widget)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
>> line 383, in convert
>>     return func(prop[0], **args)
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
>> line 116, in _set
>>     expr = [self._pyEnumMember(v) for v in prop.text.split('|')]
>>   File
>> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
>> line 111, in _pyEnumMember
>>     raise AttributeError("unknown enum %s" % cpp_name)
>> AttributeError: unknown enum QgsMapLayerProxyModel::RasterLayer
>>
>> I use QGIS LTR installed via OSGeo4W installer. Same problem also exists
>> with dev and release versions. Any ideas what is wrong and how to fix
>> this?
>>
>> Thanks
>> --
>> Alexander Bruy
>> _______________________________________________
>> Qgis-developer mailing list
>> [hidden email] <http:///user/SendEmail.jtp?type=node&node=5236556&i=0>
>> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://osgeo-org.1560.x6.nabble.com/Problem-with-using-QGIS-custom-widgets-in-plugin-tp5236556.html
>> To unsubscribe from Quantum GIS - Developer, click here.
>> NAML
>> <http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
> ------------------------------
> View this message in context: Re: Problem with using QGIS custom widgets
> in plugin
> <http://osgeo-org.1560.x6.nabble.com/Problem-with-using-QGIS-custom-widgets-in-plugin-tp5236556p5236568.html>
> Sent from the Quantum GIS - Developer mailing list archive
> <http://osgeo-org.1560.x6.nabble.com/Quantum-GIS-Developer-f4099106.html>
> at Nabble.com.
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20151116/a7d6690b/attachment.html>


More information about the Qgis-developer mailing list