I'm working on a Qgis plugin with python,

I'm creating a feature and I show a feature form to edit the attributes. But after the openFeatureForm function call the program crash and close

line = QgsFeature()
pr = parcoursLayer.dataProvider()

this is the message after crash

  • Do you get an error message or stack trace? – Branco Oct 30 '15 at 12:26
  • What kind of layer is parcoursLayer? OGR? Memory? – underdark Oct 30 '15 at 18:15
  • @Branco, i didn't get any message – badr.zr Nov 4 '15 at 12:02
  • @underdark, it's not a Memory layer, it's the current layer – badr.zr Nov 4 '15 at 12:03

we are facing the same issue here. It seems related to a bug in PyQt4.

See preloadForm method comment here for a workaround :


and here the issue raised to QT / Pyqt 4 by NathanW:



Before to set geometry of 'transformedLine' try out to print it. This object should have a form similar (if it is projected in meters) to this (for one feature):

[(366179,4.46968e+06), (357711,4.44966e+06), (363870,4.43041e+06), (382100,4.41947e+06), (396590,4.41078e+06)]

A list of QgsPoint.

The another strange thing is in:


You are passing a list where it is expected a feature but, the method 'addFeatures' does not exist in QgsDataProvider. It is in QgsVectorLayer. Normally it would be:

feat = QgsFeature()
feat.setAttributes([1]) #one feature with id = 1; several features in a loop
your_layer.addFeature(feat, True)
  • I show the transformedLine and it's a liste of QgsPoint, and I did what you said, but I have the same problem – badr.zr Nov 4 '15 at 12:04

Your Answer

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

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