kostas
kostas

Reputation: 111

How to disable OK button in QInputDialog if nothing is typed?

I want to disable the OK button until the user types something in the text field but I was unable to do it so far... Following is the excerpt of my code where the OK button is active from the beginning.

    inputDialog=QInputDialog()
    text, ok = inputDialog.getText(self, 'Input Dialog','Enter name')

    print ("text,ok",text,ok)
    if ok:
        return (text.upper(), ok)
    else: 
        return ('',ok)

Upvotes: 2

Views: 1401

Answers (1)

kostas
kostas

Reputation: 111

The comment answers the question. It is not possible with QInputDialog. Alternatively, write a custom QLineEdit obj with two buttons.

Upvotes: 2

Related Questions