Display QMessageBox with multiple arguments

2019-08-10 17:59发布

I'm using the Qt framework and I'm a little rusty with it.

I have two QStrings first and last

I want to display them in a QMessageBox but don't know how to include multiple arguments.

This is what I have to code it with on argument:

QMessageBox::information(0, "Full Name", QString("%1 %2").arg(first));

How do I get the other argument (last) included in that output?

2条回答
爷的心禁止访问
2楼-- · 2019-08-10 18:11

Yes should do something like that:

QMessageBox::information(0, "Full Name", QString("%1 %2").arg(first, last));
查看更多
Juvenile、少年°
3楼-- · 2019-08-10 18:30

All of the arg()s return a QString so the following should work:

QMessageBox::information(0, "Full Name", QString("%1 %2").arg(first).arg(last));

For more information, you can check the documentation here.

查看更多
登录 后发表回答