Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, June 2007
Re: Fixed spacing and multicoloured text? - SOLVED


Message 1 in thread

After some experimenting with various codes I found the solution 
is to embed the string in <pre> ...</pre> thus:

      intval << "<pre>" << s.x() << s.y() << s.z();
      intval.setFieldWidth(7);
      for(int i=0; i < nNoProcesses; i++)
      {
          intval << " <font color=" << processcolour[i] <<"> ";
          intval << SourceVal(source[i]) <<" </font>";
      }
      intval << "</pre>";

which gives fixed spacing & multicoloured text.

>The problem: create a string that has the following format
>(in printf style) "%4d %4d %4d %6d %6d... %6d"  and fixed 
>spacing. Also each of the %6d has a colour which shows 
>which process it comes from.
>
>Fixed format solution:
>      QString infoLabel;
>      QTextStream intval(&infoLabel);
>      intval.setRealNumberNotation(QTextStream::FixedNotation);
>      intval.setFieldWidth(5);
>      intval << s.x() << s.y() << s.z();
>      intval.setFieldWidth(7);
>      for(int i=0; i < nNoProcesses; i++)
>          intval << SourceVal(source[i]);
>
>which works perfectly when using a fixed space font. 
>
>If I try to add colour to the process values:
>
>      for(int i=0; i < nNoProcesses; i++)
>      {
>          intval << " <font color=" << processcolour[i] <<"> ";
>          intval << SourceVal(source[i]) <<" </font>";
>      }
>
>it works, but because  the string is now interpreted  as rich text 
>all of the spacing is ignored!
>
>Is there any way to generate a string with both fixed space 
>and multicoloured output?





__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--
 [ signature omitted ]