A: 去掉字符串中的空格
string tempString = text;
int begin = 0;
begin = tempString.find(" ",begin); //查找空格在str中第一次出現的位置
bool needset = false;
while(begin != -1) //表示字符串中存在空格
{
needset = true;
tempString.replace(begin, 1, ""); // 用空串替換str中從begin開始的1個字符
begin = tempString.find(" ",begin); //查找空格在替換後的str中第一次出現的位置
}
if (needset)
{
editBox->setText(tempString.c_str());
}