问题
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?
回答1:
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.
回答2:
Yes should do something like that:
QMessageBox::information(0, "Full Name", QString("%1 %2").arg(first, last));
来源:https://stackoverflow.com/questions/30062868/display-qmessagebox-with-multiple-arguments