PDA

View Full Version : Change property of QInputDialog button



Raadush
11th July 2012, 12:49
Hi, I have this problem. I have application where I use QInputDialog for passwords. What I want is to disable Ok button until user inputs at least 4 numbers into dialog. Is there some way to do it? I can retrieve length of input by reacting on signal textValueChanged(QString), but how to change property of QInputDialog button? Is it even possible? :(

Naahmi
11th July 2012, 13:20
Hi, I have this problem. I have application where I use QInputDialog for passwords. What I want is to disable Ok button until user inputs at least 4 numbers into dialog. Is there some way to do it? I can retrieve length of input by reacting on signal textValueChanged(QString), but how to change property of QInputDialog button? Is it even possible? :(


i think you cant enable/disable the standard buttons from qinputdialog.
Why you doesn't make a QWidget with QLineEdit field and implent your own qpushbutton? then you can check the length of the qlineedit and enable/disable the qpushbutton.

i think that is the better way to handle this.

Lykurg
11th July 2012, 13:50
Well, you can access the buttons:
QInputDialog d;
d.show();
QList<QDialogButtonBox*> l = d.findChildren<QDialogButtonBox*>();
if (!l.isEmpty())
l.first()->button(QDialogButtonBox::Ok)->setEnabled(false); but you shouldn't. Better code your own dialog.