gpt4 book ai didi

qt - Qt 中的 QString::sprintf 和 QString::arg 有什么区别?

转载 作者:行者123 更新时间:2023-12-03 06:31:43 25 4
gpt4 key购买 nike

QString 文档 http://doc.qt.io/qt-5/qstring.html#arg

One advantage of using arg() over sprintf() is that the order of the numbered place markers can change, if the application's strings are translated into other languages, but each arg() will still replace the lowest numbered unreplaced place marker, no matter where it appears.

这是什么意思?谁能举例说明一下吗?

最佳答案

int day = 1;
int month = 12;
int year = 2010;
QString dateString = QString(tr("date is %1/%2/%3")).arg(month).arg(day).arg(year);
// dateString == "date is 12/1/2010";

德语翻译“Das Datum ist: %2.%1.%3”: dateString = "Das Datum ist: 1.12.2010"

关于qt - Qt 中的 QString::sprintf 和 QString::arg 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4322836/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com