[Qt-interest] Problems With tr and operator <<
Thiago Macieira
thiago at kde.org
Mon Mar 15 09:06:22 CET 2010
Em Segunda-feira 15. Março 2010, às 05.04.17, Aaron Lewis escreveu:
> Sorry for sending this mail to all these address. ;-)
>
> Hi , I was reading your book , Qt/C++ Advance Programming.
> Part 12.5 , you write a image converter
>
> I rewrited this program , and add some new functions
>
> -snip-
>
> if(ui->colorBox->isChecked())
> // arg << tr("-depth
> %1").arg(ui->colorComboBox->currentText()); //fails , convert doesn't
> recognize '-depth 32'
> arg << "-depth" << ui->colorComboBox->currentText(); //
> works , don't know why
>
> -snip-
>
> Fist method doesn't work , while the second works , convert program
> tells me '-depth 32' is not recognized.
> Is there any differences between `tr' and operator `<<' ?
Yes, they are not at all the same thing.
For those of us without the book, we are without context. We don't know what
arg is, so we don't know what operator<< you're talking about.
I am going to guess it's a QStringList, used to hold the arguments to
QProcess. If I am guessing right, then operator<< is the same as
QList::append. So note the difference:
Case 1:
arg.append("-depth 32");
Case 2:
arg.append("-depth");
arg.append("32");
One creates one argument that includes a space. The other creates two
arguments.
Also note how it makes no sense to translate "-depth" to another language,
since convert cannot understand anything other than "-depth".
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100315/d2073a8d/attachment.bin
More information about the Qt-interest-old
mailing list