//应用程序抽象类
#include<QApplication>
//按钮
#include <QPushButton>
//窗口类
#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);
w.setWindowTitle("Hello World");
//输入密码时
//edit.setEchoMode(QLineEdit::Password);
//edit.text();
//edit.setPlaceholderText("please input text");
QCompleter completer(QStringList()<<"aab"<<"123"<<"998");
completer.setFilterMode(Qt::MatchContains);
edit.setCompleter(&completer);
//显示窗口
w.show();
//在exec中有一个消息循环,所以窗口才会一直存在
return app.exec();
}
.PRO:
SOURCES += \
main.cpp
QT+=widgets gui