Qt Port update.

Dirk Hohndel dirk at hohndel.org
Sat Apr 13 20:47:52 PDT 2013


Thiago Macieira <thiago at macieira.org> writes:

> On sábado, 13 de abril de 2013 14.25.24, Dirk Hohndel wrote:
>> void MainTab::clearStats()
>> {
>>         QList<QLabel*> labels;
>>         labels << ui->maxdepth_2 << ui->mindepth << ui->avgdepth
>>                 << ui->maxsac << ui->minsac << ui->avgsac
>>                 << ui->dives << ui->maxtemp << ui->mintemp << ui->avgtemp
>>                 << ui->totaltime << ui->avgtime << ui->longestdive <<
>> ui->shortestdive;
>> 
>>         Q_FOREACH(QLabel *l, labels){
>>                 l->setText(QString());
>>         }
>> }
>> 
>> What exactly does that series of '<<' do in this context? I find this
>> particularly hard to read...
>
> In class QList:
>
>     inline QList<T> &operator<< (const T &t)
>     { append(t); return *this; }
>
> That operator is very useful in some contexts. Here, Tomaz was using to add 
> all the labels to one QList so he could use foreach on the list. 

I repeat - I find this incredibly hard to read...

> But since all the labels were listed anyway, wouldn't it be easier to just 
> call setText(QString()) on them directly?
>
> Probably more efficient too.

Yeah, I think I'd prefer that.

/D


More information about the subsurface mailing list