是不是在使用QGraphicsTextItem时发现没有setPen和setBrush函数?查看帮助文档确实如此,细看发现它和QGraphicsRectItem继承的类还不一样。
当然,Qt还是替你考虑的挺周全的。提供了函数void QGraphicsTextItem::setDefaultTextColor(const QColor & col)。 //Sets the color for unformatted text to col.
文本在无格式的时候就用这颜色。 如果你用setHtml设置了颜色就不需要它了。
更多详细内容请查看:fearlazy.com