禁用日语的QLineEdit密码字段中的预测文本

时间:2016-07-07 10:12:55

标签: windows qt

我有一个小的Qt代码,我们从中获取用户的密码。

现在,当我在密码框中输入文本时,它开始预测文本。这种情况仅发生在日语操作系统中而非英语操作系统中

如何禁用文字预测? 它还在密码字段中显示文字!!

enter image description here

代码

#include <QCoreApplication>
#include <QApplication>
#include <QMainWindow>
#include <QLineEdit>
#include <QHBoxLayout>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QMainWindow *window = new QMainWindow();

        window->setWindowTitle(QString::fromUtf8("QLineEdit Password Style"));
        window->resize(336, 227);

        QWidget *centralWidget = new QWidget(window);
    QHBoxLayout *layout = new QHBoxLayout();

    centralWidget->setLayout(layout);
    QLineEdit *lineEdit = new QLineEdit(centralWidget);

    //Set QLineEdit Echo Mode Here so that
    //asterisks will be shown when values are entered
    lineEdit->setEchoMode(QLineEdit::Password);
    lineEdit->setInputMethodHints(Qt::ImhHiddenText| Qt::ImhNoPredictiveText|Qt::ImhNoAutoUppercase);
    //lineEdit->setAttribute( Qt::WA_InputMethodTransparent, true );


    //Add to horizontal layout to center qLineEdit
    layout->addWidget(lineEdit);
    lineEdit->setFixedSize(300, 20);

    window->setCentralWidget(centralWidget);

    window->show();
    return app.exec();
}

0 个答案:

没有答案