[英]how to change the color of a QGraphicsTextItem
i have a scene with a multiple (QGraphicsTextItem)s, and i need to have control over their colors , so how to change a color of a QGraphicsTextItem ? 我有一个带有多个(QGraphicsTextItem)的场景,我需要控制它们的颜色,那么如何更改QGraphicsTextItem的颜色? is it possible anyway?
反正有可能吗? i've been trying for 3 days until now .
到目前为止我已经尝试了3天。 please help
请帮忙
thanks in advance 提前致谢
setDefaultTextColor(col) "Sets the color for unformatted text to col." setDefaultTextColor(col)“将未格式化文本的颜色设置为col。” The documentation is not clear about what "unformatted text" means.
文档不清楚“无格式文本”的含义。 I think it means: "all portions of the contents of the item that have not been styled."
我认为这意味着:“项目内容的所有部分都没有被设置样式。”
The contents is a QTextDocument. 内容是QTextDocument。
You style a part of a document using a QTextCursor. 您使用QTextCursor设置文档的一部分。 You can't style the QTextDocument per se, only a part that is selected by a QTextCursor (but you can select the whole document.)
您不能设置QTextDocument本身的样式,只能设置由QTextCursor选择的部分(但您可以选择整个文档。)
You can style a QTextCursor using method mergeCharFormat(QTextCharFormat) 您可以使用方法mergeCharFormat(QTextCharFormat)设置QTextCursor的样式
The QTextCharFormat has methods: QTextCharFormat有方法:
Foreground is a QBrush that paints several things including "text" (but better said: the fill of characters?) 前景是一个QBrush,它描绘了几个东西,包括“文本”(但更好地说:填充字符?)
One nuance is that certain newly constructed QBrush have (default to) QBrushStyle.NoBrush, which is transparent, even if you setColor(). 一个细微差别是某些新构造的QBrush具有(默认为)QBrushStyle.NoBrush,即使你使用setColor()也是透明的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.