Qt Port update.

Thiago Macieira thiago at macieira.org
Sat Apr 13 17:37:52 PDT 2013


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. 

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.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130413/b98a705b/attachment.sig>


More information about the subsurface mailing list