I'm developping a QGIS Plugin where the User clicks on the map, my plugin make a buffer and propose a street name, a street side and a disctrict, then the user selects which administration he's from and the status of the building select. After this the User needs to puts 3 values to add to our database.

So, I have a box with several inputs from the user.

enter image description here

I would like to set the "ok" button enabled only when all the inputs are filled.

Is there anyway to 'check' if everything is filled in each function and tell the button "ok you can go". Like the Checkbox but without a check by the user?

Here under part of the code for the first line with an user's input (adpn):

        self.adpn_text = QLineEdit()
        self.layout.addRow(QLabel("Entrer l'ADPN (format = num):"), self.adpn_text)

    def get_values_adpn(self, text):
        self.adpn_values = text

    def click_ok (self, click):
        print("--- Récupère les données de l'User---")
        print('ADPN User', self.adpn_values)

2 Answers 2


I would implement the following. (It's an incomplete example but hopefully you get the idea and can adapt for your application). Store all your line edit widget objects in a list and, for each one, connect its textChanged signal to a slot function so that anytime the text is changed in any of the line edits, the function is called.

In the slot function, iterate over all the line edit text values and, if any of them are an empty string, set the OK button to not enabled.

    self.edits = [w for w in self.children() if isinstance(w, QLineEdit)]
    for w in self.edits:

def edit_text_changed(self, text):
    if self.edits[0].text() == '' or self.edits[1].text() == '' or self.edits[2].text() == '':

enter image description here


Usually, you would check after each input event if the conditions for allowing the user to click OK are met and if they are you "enable" to OK button.

  • 4
    Should this question really be classed as off-topic? The question is related to QGIS plugin development which sounds on-topic for GIS:SE in my opinion :)
    – Joseph
    Oct 16, 2019 at 9:12
  • There is nothing QGis specific about it - see gis.meta.stackexchange.com/questions/3250/… for the last time we discussed this issue
    – Ian Turton
    Oct 16, 2019 at 9:41
  • In that case, should the following questions be also flagged as off-topic? 1, 2, 3
    – Joseph
    Oct 16, 2019 at 9:47
  • This is not the place to discuss this - feel free to ask on meta.gis if you want to reopen this discussion
    – Ian Turton
    Oct 16, 2019 at 10:31

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.