2

I'm working on my first plug-in. In an attempt to validate the user selections on the dialog, I am using a message box to return messages to the user if an error is found. The messgae box displays properly, however when the user selects the ok, the dialog closes along with the message box. How do I control the behavior of the message box so only it will close and not the dialog too?

    def validate(self):

    message = ''

    if len(self.myListWidget.selectedItems()) == 0:
        message = 'Choose at least 1 Soil Survey Area'

        QMessageBox.critical(self, 'Execution Error', message)
  • Do you have a close statement somewhere in your code for the dialog? – artwork21 Jul 8 '16 at 19:47
1

In answer to my own question...The QMessageBox was called upon execution of the plugin so it only makes sense the main dialog closed after calling the QMessageBox. The quick answer was to create a separate push button allowing the user to validate the entries at any point.

Ultimately what I'd like is to have some sort of object listening in the background that keeps the OK (accept) button disabled until all the appropriate parameters have been correctly entered. After which, the OK button would be enabled.

  • Did you find how to do your second idea ? – Svhooren Oct 15 at 11:59

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.