Hey there.
I'm using a QTextDocument to display paragraphes.
Is there a way to set the "default" text color.
Thanks.
Hey there.
I'm using a QTextDocument to display paragraphes.
Is there a way to set the "default" text color.
Thanks.
Qt Code:
mTextDocument->setDefaultStyleSheet(style.arg(mColor.red()). arg(mColor.green()). arg(mColor.blue()));To copy to clipboard, switch view to plain text mode
Tried this with no success.
Shouldn't it be QString("color: %1;").arg(mColor.name()) ?
Should be working with rgb :/.
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?
Actually it's not set in a widget,
I use the TextDocument for HTML strings that are displayed by my view's paint event.
Last edited by bunjee; 15th April 2008 at 18:04.
Why don't you add the style definition to the html manually?
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 .
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.
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.
Bookmarks