#include<QApplication>
#include<QLineEdit>
#include<QCompleter>
int main(int argc,char* argv[])
{
QApplication app(argc,argv);//1
QWidget w;//2 构造一个窗口
w.setWindowTitle("Hello World!");//设置窗口标题
QLineEdit edit;
edit.show();
edit.setParent(&w);
/*输入密码*/
//显示输入密码的样子LineEdit有四种显示模式
//Normal NoEcho PassWord PasswordEchoOnEdit
//edit.setEchoMode(QLineEdit::Password);//1
//edit.text();
//edit.setEchoMode(QLineEdit::NoEcho);//2
//edit.setEchoMode(QLineEdit::PasswordEchoOnEdit);//3
/*输入密码提示*/
//edit.setPlaceholderText("Please input text");
/*补全*/
QCompleter completer(QStringList() << "aab"<< "1122" << "998");
//completer.setFilterMode(Qt::MatchContains);有错误
edit.setCompleter(&completer);
w.show();//3默认情况下隐藏,需要用show显示出来
/*发送信号的对象 发送对象 接收信号的对象 要执行的槽*/
//QObject::connect(&button,SIGNAL(clicked()),&w,SLOT(close()));
return app.exec();//4
}
QT --------にQLineEdit
おすすめ
転載: blog.csdn.net/QQ960054653/article/details/64186160
おすすめ
ランキング