Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a QGIS project with some layers without geometry. I develop a QGIS plugin. I want to get all my layers by:


but I get only layers with geometry. How I can get layers without geometry?

My no-geometry layers are just tables in a database. I could connect to the database in order to access data but I would like to know whether it is possible to access them as QGIS layers (in analogous way to QgsVectorLayers).

share|improve this question
You don't say what version of QGIS you are using, but the method you describe works for PostGIS data at both QGIS 1.8 and the latest development version. – gsherman Sep 4 '13 at 0:50
@gsherman I use QGIS 1.8 but I can't get no-geometry layers from iface.mapCanvas().layers(). How I can get them without connecting directly to a database? – tomto Sep 4 '13 at 5:41
@tomto try to post somewhere one of these "layers" without geometry to download (I never see one...), I would like to try. – G M Sep 9 '13 at 12:38
up vote 2 down vote accepted

Do not use iface.mapCanvas().layers().

Use QgsMapLayerRegistry.instance().mapLayers() instead.

QgsMapLayerRegistry contains all layers from current QGIS project - also layers without geometry.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.