Hot answers tagged

5

Let me share how it works for me: self.setWindowTitle(title) #data = 'Recordset back from postgis' nb_row = len(data) nb_col = 2 qTable.setRowCount(nb_row) qTable.setColumnCount(nb_col) for row in range (nb_row): for col in range(nb_col): item = QTableWidgetItem(str(data[row][col])) qTable.setItem(row,col,item) ...


5

Better than a script, there's a plugin to achieve it, and it's called "Remove empty layers from the map." http://plugins.qgis.org/plugins/RemoveEmptyLayers/ Disclaimer: I'm the plugin's author.


4

Right, you need to use QSettings to store values across QGIS sessions. QSettings is multi-platform, so you don't need to worry about where it stores the data on Linux, on Windows, or on Mac, it handles it for you. You need to call QSettings in this way: from PyQt4.QtCore import QSettings settings = QSettings() You can use QSettings() every time you ...


4

The error occurs because the plugin (in its version 0.51) does not filter out Raster layers from the QGIS ToC and lists them in its own GUI. The plugin should only deal with Vector layers, since it acts on vector geometries. I sent a pull request to the plugin's author with code to fix this problem, which was accepted and merged by him. The author has just ...


2

Without knowing exactly where you're up to it's a bit difficult, but here's the nuts and bolts: layermap = QgsMapLayerRegistry.instance().mapLayers() RemoveLayers = [] for name, layer in layermap.iteritems(): if layer.isValid(): if layer.type() == QgsMapLayer.VectorLayer: if layer.featureCount() == 0: ...


2

In my opinion, a much easier way to use an "in house" plugin is to place a copy in the following directory: C:\OSGeo4W\apps\qgis\python\plugins Also within this directory you will see other plugins that are installed as core plugins that come with the OSGEO4W download of QGIS. After placing a copy of your custom plugin into this directory, be sure to go ...


2

Many QGIS Plugins uses GitHub as their primary issue tracker. Issue tracker is usually specified in the plugin's metadata <home>/.qgis2/python/plugins/<plugin>/metadata.txt. For plugins that use GitHub issue tracker, one can use Report plugin to facilitate reporting of the bugs/enhancements.


2

The error message 'module' object has no attribute 'openssl_md_meth_names' seems to be related to python, see https://github.com/Homebrew/legacy-homebrew/issues/36346 for MAC OS and http://stackoverflow.com/questions/27890225/attributeerror-module-object-has-no-attribute-python for linux. QGIS usually has its own python to run, but if your system PATH has ...


2

QMS is certainly installable using Ubuntu 14.04 and QGIS 2.14.1 so I suspect your issue is the age of your QGIS install if it really is 2.0.


2

To automatically open the QGIS Python Console when QGIS starts, you can read How to show Python console at QGIS program start. However, I guess your ultimate intention is to run the script (even if it doesn't run from the QGIS Python Console), so you can create (if it doesn't exist already) a startup.py file in the QGIS Python directory: On GNU/Linux: ...


2

By using a temporary file, as reassignment of the standard output (Python Console), next code works. ... import sys, os import tempfile as tmpf ... else: #save a reference to the Python Console of QGIS before reassignment oldstdout = sys.stdout #creating a temporary file file = ...


2

You can create views on your table to access the different geometry types as separate layers in QGIS, for example: CREATE VIEW parcel_polygons AS SELECT id, name, geom::geometry(MultiPolygon, 4326) FROM parcels WHERE GeometryType(geom) = 'MULTIPOLYGON'; CREATE VIEW parcel_points AS SELECT id, name, geom::geometry(Point, 4326) FROM parcels WHERE ...


1

You can use None as output parameter. Doing so, QGIS Processing creates a temporary vector file for you: processing.runandload("qgis:createpointsalonglines", "Clipped" ,100,0,0,None) Or: res = processing.runalg("qgis:createpointsalonglines", "Clipped" ,100,0,0,None) iface.addVectorLayer(res['output'],'my points','ogr') In my case (on a GNU/Linux), the ...


1

Even though you're running the QGIS Desktop with GRASS the GRASS plugin is not on by default, you have to go to Plugins -> Manage and Install... then to the installed plugins. There you'll find an entry for GRASS 7, check its box and then you'll have the GRASS tools under the plugin menu. If you don't have the GRASS 7 entry in the installed plugins go back ...


1

rasterMenu = qgis.utils.iface.rasterMenu() for rasterMenuItem in rasterMenu.actions(): if 'Heatmap' in rasterMenuItem.text(): heatmapMenu = rasterMenuItem for heatmapMenuItem in heatmapMenu.menu().actions(): print heatmapMenuItem if 'Heatmap' in heatmapMenuItem.text(): heatmapMenuItem.trigger()


1

Found a way, basically you just need to specify the column when populating the QTableWidget (mentioned in comment): qTable = self.dockwidget.tableWidget data = [] group1 = root.findGroup('Group1') group2 = root.findGroup('Group2') for child in group1.children(): data.append(child.name()) for child in group2.children(): data.append(child.name()) ...


1

Solution is not to change the compiler, because QGIS compilation was succesful, just my plugins gave the error. So I scrabble about sth in the project properties of qgis and found a preprocessing directive /D nullptr=0 This I copied to my plugins and it worked fine. Don't know, when this was added. Also don't know where to get the information, if sth. ...


1

What finally worked was uninstalling the later version of python (2.7.10) and setting the paths to the OSGeo4W64 python directory (while maintaining my arcgis python directories). I then reinstalled the later version of python and qgis runs without issue. Perhaps I didn't need to do the uninstall and reinstall and could have just confirmed and reordered the ...


1

import os from PyQt4 import QtGui, uic from PyQt4.QtCore import pyqtSignal FORM_CLASS, _ = uic.loadUiType(os.path.join( os.path.dirname(__file__), 'my_dockwidget_base.ui')) class myDockWidget(QtGui.QDockWidget, FORM_CLASS): closingPlugin = pyqtSignal() def __init__(self, parent=None): """Constructor.""" super(myDockWidget, ...



Only top voted, non community-wiki answers of a minimum length are eligible