PDA

View Full Version : QString::arg: Argument missing



BalaQT
4th May 2011, 11:48
hi,
I'm using linguist to translate the following, (environment: ubuntu,qt4.7)

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QTranslator translator;
QString txt1="text";
translator.load("testLang");
qApp->installTranslator(&translator);
ui->setupUi(this);
l=new QLabel(this);
l->setText(tr("file %1").arg(txt1));
}

But I'm getting the following warning:
QString::arg: Argument missing: test translatedText, text
(translatedText: The text translated in the target language.)
what's the possible cause , how can i get rid of this?
Thanks in advance.
Bala

wysota
4th May 2011, 12:19
The translation probably doesn't contain "%1".

BalaQT
4th May 2011, 13:33
hi master,
Thanks for 'your reply' (thought of using 'ur reply' :) afraid of your infractions :) ).


The translation probably doesn't contain "%1".
In translation I'm having 'file translatedText' for the code tr(file %1).arg(txt1).
My assumption is the translatedText will be placed in the %1. Is it right?

Note: I'm getting the output correctly, But I want to remove the warning.
May be a simple thing, which I'm missing completely.

Thanks,
Bala

wysota
4th May 2011, 14:57
My assumption is the translatedText will be placed in the %1. Is it right?
No. %1 is for QString::arg() to work. And it needs to be present in the translated string as well.