Qt之QLineEdit學習

#include <QApplication>
#include <QWidget>
#include <QLineEdit>
#include <QCompleter>
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWidget w;

    QLineEdit edit;
    edit.show();
    edit.setParent(&w);

//   edit.setEchoMode(QLineEdit::Password);  //輸入密碼
//   edit.setEchoMode(QLineEdit::Normal);   //正常顯示
//   edit.setEchoMode(QLineEdit::NoEcho);
//   edit.setEchoMode(QLineEdit::PasswordEchoOnEdit);
//    edit.text();
//    edit.setPlaceholderText("Please input text: ");
    
    QCompleter completer(QStringList() << "aab" << "123" << "998");
    completer.setFilterMode(Qt::MatchContains);  //設置補全模式:默認MatchStartsWith
    edit.setCompleter(&completer);   //自動補全功能

    w.show();
    w.setWindowTitle("Hello world");
    w.show();
    return app.exec();
}

相關文章
相關標籤/搜索