Timeline for Pyqgis - selectedFeatures() doesn't seems to work
Current License: CC BY-SA 3.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 22, 2017 at 19:06 | vote | accept | Gingerbread | ||
Aug 22, 2017 at 19:05 | answer | added | Gingerbread | timeline score: 1 | |
Aug 22, 2017 at 14:31 | answer | added | Sassá | timeline score: 1 | |
Jun 18, 2017 at 22:06 | comment | added | Gingerbread | After reading this other thread [link]gis.stackexchange.com/questions/160565/… and testing with another way to access layers (lay = qgis.utils.iface.legendInterface().layers()) that worked for me it seems that the problem resides in the QgsMapLayerRegistry instance. Anyway thanks for your help Steven and @adamczi | |
Jun 18, 2017 at 21:48 | comment | added | Gingerbread | Print layer1.name() gives me the name of the chosen layer. I, then, tried your suggestion and it printed me every features contained in the vector layer but still doesn't printed any selected features while I can assure there are. But I think I might be on a track here. When I ask to print every name of the layers via QgsMapLayerRegistry.instance().mapLayers.values() it gave me 4 layers with the exact name of the one I want to iterate over. | |
Jun 18, 2017 at 12:03 | comment | added | adamczi |
What is the output of print layer1 ? And what happens when you do for feature in layer1.getFeatures(): print feature ? Does it return anything? If all of above works fine, how about first setting selected features to none using layer1.setSelectedFeatures([]) , then select some of them through Python console and then check what selectedFeatures() give you?
|
|
Jun 18, 2017 at 9:07 | comment | added | Gingerbread | I'm using Qgis 2.18.1 and I just typed this code in the console but I want to use it in an init python function to link a vector layer and a table. I know the code is ok because I've already succeeded to do it and it seems to still works with other layers so I'm really puzzled. | |
Jun 18, 2017 at 8:53 | history | edited | Gingerbread | CC BY-SA 3.0 |
- Edited QGis version
|
Jun 17, 2017 at 23:22 | history | edited | PolyGeo♦ |
edited tags
|
|
Jun 17, 2017 at 23:11 | comment | added | Steven Kay | code looks OK... what version of QGIS, and is this from the python console or somewhere else (plugin / processing script / standalone script)? Just tried this on QGIS 2.18.7 (from the python console) with a spatialite layer and your code seems to work for me. | |
Jun 17, 2017 at 22:34 | review | First posts | |||
Jun 17, 2017 at 23:15 | |||||
Jun 17, 2017 at 22:33 | history | asked | Gingerbread | CC BY-SA 3.0 |