How to set background inactive and grey while i put a password to a QInputDialog in QT?

210 views Asked by At

How to set background inactive and grey while i put a password to a QInputDialog in QT? I have an qmainwindow app and i would like to do this. Thanks your help! :)

bool ok;
    QString sPassword =  QInputDialog::getText(this, "Enter Password", "Password: ", QLineEdit::Password, "",&ok);
    if(ok && QString::compare(sPassword,"goodpassword",Qt::CaseInsensitive)==0)
        QApplication::quit();
1

There are 1 answers

0
Vince759 On BEST ANSWER

Your background should be inactive. The QInputDialog::getText is modal by default, see the doc: https://doc.qt.io/qt-5/qinputdialog.html#getText

To grey out your application when the dialog is opened I'd say either play with the stylesheet or create your custom dialog that paints a grey rectangle on top of the application.