Qt-interest Archive, June 2007
Fixed spacing and multicoloured text?
Message 1 in thread
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?
DS
Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know at http://ca.answers.yahoo.com
--
[ signature omitted ]
Message 2 in thread
One way may be replacing all spaces by " " which is "real space"
in the rich text format., like this:
string=string.replace(" "," ");
Martin Petricek
On 6/5/07, David Scriven <davidwriter@xxxxxxxxx> wrote:
> 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?
>
> DS
>
>
>
>
> Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know at http://ca.answers.yahoo.com
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]