2

am getting error while parsing a selected feature to the lineEdit like, QLineEdit.setText(QString): argument 1 has unexpected type 'long'

layer = self.iface.activeLayer()
    h = layer.selectedFeatures()
    for f in h:
        g =  f['ID']
    self.dlg.lineEdit.setText(g)

2 Answers 2

1

self.dlg.lineEdit.setText(str(g)) is also not working but i got the solution

self.dlg.lineEdit.setText('{}'.format(g))
0

At first glance, the problem seems obvious: f['ID'] is not a string, it is a number of the long type, which is not accepted by the function.

Simply converting it by using self.dlg.lineEdit.setText(str(g)) should be enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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