PDA

View Full Version : how to concatenate a variable with a string



doforumda
25th August 2010, 08:28
hi i am trying to concatenate a variable with a string. How can i do this?
here is the code


void login::show_user()
{
QString user_name = user->text();
QMessageBox::information(this, tr("Your Username"),
tr("Your username is user_name"));
}


i want to concatenate user_name in QMessageBox to display username

aamer4yu
25th August 2010, 08:34
You can simply use + operator, or opt of string arguments..
QString message = "Your user name is " + user_name;
QString message = QString("Your user name is %1").arg(user_name).

Do read Qt Assistant..it helps