使用QInputDialog将用户输入读取为单个字符串

时间:2014-07-23 09:01:07

标签: qt

我正在尝试使用QInputDialog将用户输入作为单个字符串读取,格式为名字:姓氏:员工编号

我该怎么做?

1 个答案:

答案 0 :(得分:0)

bool ok;      

QString text = QInputDialog::getText(  this,  tr("Label dialog"),  
           tr("Enter employee data as firstName:lastName:empNumber"),   
           QLineEdit::Normal, "", &ok );  
if( ok && !text.isEmpty() )  
{
    // pull apart the results here.
}