0

I am building a plugin in python for Qgis. I want the users to be able to start typing a text and that auto compellation to pop up based on values in a certain field I will define. Is this possible and how? Is there an appropriate widget for this purpose?

1
  • Hope you are happy and healthy. I am looking for the same plugin. Have you build this plugin? Would you mind to share it? Can we use it with default QGIS Data Entry Form? Thanks in anticipation. – Furqan Saeed Dec 14 '18 at 7:34
2

In QGIS 3.0, yes. There's a QgsFieldValuesLineEdit widget which handles this for you, including background threaded load of the field values so that your application remains responsive.

You can use it by:

w = qgis.gui.QgsFieldValuesLineEdit()
w.setLayer(my_vector_layer)
w.setAttributeIndex(0) # or 1, 2,.. depending on which field you want to show
w.show()

Full docs are available at https://qgis.org/pyqgis/3.4/gui/QgsFieldValuesLineEdit.html

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.