I am developing a plug-in for QGIS. I am creating a form of personalized editing using QtCreator. The form is in the following image

enter image description here

I read a csv file and when i click in a button OK I get a layer with any desired points

My goal: When I click on the "SELECT POINT" I want plot a graph with the point attributes. I see this code

   class nameform:
    """QGIS Plugin Implementation."""

    def __init__(self, iface):

        self.iface = iface

        self.canvas = self.iface.mapCanvas()

    def open_graph(self):
        self.pointEmitter = QgsMapToolEmitPoint(self.iface.mapCanvas())
        QObject.connect( self.pointEmitter, SIGNAL("canvasClicked(const QgsPoint, Qt::MouseButton)"), self.selectNow)
        self.iface.mapCanvas().setMapTool( self.pointEmitter )  

    def selectNow(self, point, button):
        layer = self.iface.activeLayer()
        if not layer or layer.type() != QgsMapLayer.VectorLayer:
            QMessageBox.warning(None, "No!", "Select a vector layer")
        width = self.iface.mapCanvas().mapUnitsPerPixel() * 2
        rect = QgsRectangle(point.x() - width, point.y() - width, point.x() + width, point.y() + width)
        rect = self.iface.mapCanvas().mapRenderer().mapToLayerCoordinates(layer, rect)
        layer.select([], rect)
        feat = QgsFeature()
        ids = []
        while layer.nextFeature(feat):
            ids.append( feat.id() )
        layer.setSelectedFeatures( ids )         

But i have a error. When i click in select point and i pick in the point gives me this error

TypeError: arguments did not match any overloaded call:
  QgsVectorLayer.select(QgsRectangle, bool): argument 1 has unexpected type 'list'
  QgsVectorLayer.select(int): argument 1 has unexpected type 'list'
  QgsVectorLayer.select(unknown-type): too many arguments
  • TypeError is suggesting to change layer.select([], rect) for layer.select(rect, True). – xunilk Sep 10 '15 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.