Hi, On 29/07/2015 17:50, Ludovic Delauné wrote: > Hi devs, > > i'm trying to use the QgsBrowserModel in a Python plugin. > I need to get the URI from a selected Item in the QTreeView, i expected to > have a QgsLayerItem returned by the dataItem() in order to get the uri() > member but a QgsDataItem > is returned instead. > Given a QgsDataItem, is it possible to get the uri of my data source ? > > Is this a bug due to the binding > (https://github.com/qgis/QGIS/blob/feb3bee85837d707b1b10c14064fcb55364e282d/python/core/qgsbrowsermodel.sip) > or i'm not in the right way ? > > Here are the few steps to reproduce the problem in a console: > > ------- > from PyQt4.QtGui import QTreeView > tv = QTreeView(None) > m = QgsBrowserModel() > tv.setModel(m) > tv.show() > m.dataItem(tv.currentIndex()) > -------- > output is : > <qgis._core.QgsDataItem object at 0x7f6cb8bcca68>
Apparently, this is because QgsDataItem has nothing to convert to its derived types in the Python bindings. I'll add a %ConvertToSubClassCode. Thanks for the report _______________________________________________ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer