View Full Version : QTextDocument color
bunjee
15th April 2008, 11:40
Hey there.
I'm using a QTextDocument to display paragraphes.
Is there a way to set the "default" text color.
Thanks.
bunjee
15th April 2008, 14:04
QString style = "color: rgb(%1,%2,%3);";
mTextDocument->setDefaultStyleSheet(style.arg(mColor.red()).
arg(mColor.green()).
arg(mColor.blue()));
Tried this with no success.
wysota
15th April 2008, 14:09
Shouldn't it be QString("color: %1;").arg(mColor.name()) ?
bunjee
15th April 2008, 14:12
Should be working with rgb :/.
wysota
15th April 2008, 14:48
What do you do with the document afterwards? Maybe it's enough to set the color in the object (widget?) used as a container for the document?
bunjee
15th April 2008, 17:48
Actually it's not set in a widget,
I use the TextDocument for HTML strings that are displayed by my view's paint event.
wysota
15th April 2008, 19:30
Why don't you add the style definition to the html manually?
bunjee
16th April 2008, 01:37
I was thinking doing so. I was just checking that nobody had a better solution.
And beside I'm not a big fan of Html parsing :).
wysota
16th April 2008, 07:51
You can also set a QTextFormat for each document block. Setting a pen with a colour of your choice on the painter in the paint event before painting might also help.
bunjee
25th April 2008, 18:54
Unfortunately, that didn't help,
I'm still trying to figure out how I can set a default color for a QTextDocument without erasing html tags and stuff like that.
Changing the pen in the paint event has no effect.
There's got to be some convenient way to do so.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.