[Qt-interest] Problems With tr and operator <<
Aaron Lewis
aaron.lewis1989 at gmail.com
Mon Mar 15 14:41:12 CET 2010
Thiago Macieira wrote:
> 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:
>
>
Right , args is a QStringList , used as parameter of QProcess.
> 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.
>
>
I use `tr' to append strings , maybe i should try with QString("-depth
%1").arg("32") , it's a mis-use .
Still not working too , I'm wondering why.
> Also note how it makes no sense to translate "-depth" to another language,
> since convert cannot understand anything other than "-depth".
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
Best Regards,
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4r0n on freenode
More information about the Qt-interest-old
mailing list