QGraphicsTextItem如何设置文本颜色?

来源:互联网 发布:淘宝查询信誉网站 编辑:程序博客网 时间:2024/04/30 04:40

     是不是在使用QGraphicsTextItem时发现没有setPen和setBrush函数?查看帮助文档确实如此,细看发现它和QGraphicsRectItem继承的类还不一样。 

当然,Qt还是替你考虑的挺周全的。提供了函数void QGraphicsTextItem::setDefaultTextColor(const QColor & col)。 //Sets the color for unformatted text to col.

             文本在无格式的时候就用这颜色。 如果你用setHtml设置了颜色就不需要它了。


0 0