1. 程式人生 > 其它 >Qt之QLineEdit學習

Qt之QLineEdit學習

技術標籤:csshtml

#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();
}

7f6516eda04cab32ef797692355cfc14b6d.jpg