问题
for a project I'm forced to use qsTrId
for i18n and I'm now in need of arguments in the string.
Sadly, the documentation for the command does not help about.
I've this sample code:
Text {
id: someId
//% "%1 my translatable suffix!"
text: qsTrId("my_translatable_id_with_argument").arg("This is")
}
It will output the following error:
QString::arg: Argument missing: my_translatable_id_with_argument, This is
The documentation for arg say it need to work with strings, so I fear that the my_translatable_id_with_argument
defined for qsTrId
is used as base string for .arg
and since there is no %1
the error is generated.
Anyone has a tip for this situation?
Thanks in advance!
EDIT:
I've tried the following with no success:
Text {
id: someId
//% "%1 my translatable suffix!"
text: qsTrId("my_translatable_id_with_argument")
Component.onCompleted: {
text = text.arg("This is")
}
}
来源:https://stackoverflow.com/questions/47183038/qstrid-and-arg-how-to-use-it