Display QMessageBox with multiple arguments

只谈情不闲聊 提交于 2019-12-11 09:07:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!