PDA

View Full Version : Modifying a text



jaca
6th May 2008, 16:29
Hello staff!

I have the following:

tr("<p>CDP Range First CDP 771 Last CDP 17146, " \
"Num. of CDPs 16376 CDPs." \
"<p>CDP Interval 6.25" \
"Total Distance 102350 Meters.")

I'm printing this in a file that will be used later. Only that the numbers will be constantly changed by the user. When the user clicking the "button", the numbers are in a "line edit" that must replace the text.
Excuse me the english, I'm Brazilian.
Somebody can help me? :D

mitro
6th May 2008, 16:35
Take a look at QString::arg function.

jaca
6th May 2008, 16:44
But the text should contain many lines. Then I use several QString::arg?

mitro
6th May 2008, 16:50
Yes. Your code may look like this:

QString firstCDP = tr("771");
QString lastCDP = tr("17146");
QString string = QString(tr("<p>CDP Range First CDP %1 Last CDP %2, ")).arg(firstCDP).arg(lastCDP);
You can easily expand this for larger pieces of text.