Search code examples
c++qtargumentsqstringqmessagebox

Display QMessageBox with multiple arguments


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?


Solution

  • 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.