输入对话框用于接收用户的输入,如我们要接收用户输入一个字符串,可以使用:QInputDialog::getText():
bool ok;
QString text = QInputDialog::getText(this, tr("Input You Name"),
tr("User name:"), QLineEdit::Password/*QLineEdit::NoEcho*/,
"Mr Zhang", &ok);
if (ok && !text.isEmpty())
QMessageBox::information(NULL,"notice",text);
参数:
1、父组件指针;
2、对话框的标题;
3、指导用户输入的提示语句;
4、对话框的输入模式;
5、输入框中的默认字符串;
6、接收返回值,用户按下ok,返回true,用户按下cancel,返回false。
类似函数还有:getint()、getitem()......