[Qgis-user] Selection issue for large set of features

Yves Moisan ymoisan at videotron.ca
Thu Dec 10 13:20:33 PST 2015


> I would like to use selectedFeaturesIds() but I can't rely on ids 
> returned being the actual PK.
A way to circumvent the PK identification issue on a PG view :

- load layers whichever way (browser, DB Manager, etc.); at this time 
keyColumn() on a QgsDataSourceURI object made from that layer will be 
whatever int4 field is the most probable candidate for a PK
- save the project file
- open project file in a text editor, search *key='* and check the value 
corresponds to the actual field name you want in postgis <maplayer> 
items; if not, change it
- reopen QGIS and voilĂ  : keyColumn() returns the expected value and 
selectedFeaturesIds() too

Yves


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20151210/3f7f03c4/attachment.html>


More information about the Qgis-user mailing list