[mythtv] mythmusic patch - trivial

Matt Zimmerman mdz at debian.org
Sun Apr 6 18:35:21 EDT 2003


On Sun, Apr 06, 2003 at 01:13:42AM -0800, Brent Hills wrote:

>      for(digits=1,by10=10;(max/by10) >=1 ;by10*=10,digits++);
> -    sprintf(temp,"%%0%ii",digits);
> +    QString temp(QString().sprintf("%%0%ii",digits));
>      for(int x=0;x<max;x++)
>      {
>          litem=listlist.at(playlistorder[x]);
> -        litem->setText(0,QString().sprintf(temp,x));
> +        litem->setText(0,QString().sprintf(temp.ascii(),x));
>      }

There is a simple printf idiom which replaces all of this, e.g.:

litem->settext(0,QString().sprintf("%*d", digits, x);

So that you don't need to build up the format string dynamically.

If you want to do this in Qt style, Qt provides a QTextOStream:

http://doc.trolltech.com/3.1/qtextostream.html

Which acts like a C++ ostream, with the usual (and quite different from
printf) formatting operators.


-- 
 - mdz


More information about the mythtv-dev mailing list