How to draw colored text on QGraphicsScene?

前端 未结 3 950
渐次进展
渐次进展 2021-01-14 05:35

I was looking for options like QGraphicsTextItem::setPen(), or even QFont::setColor() or QFont::setForegroundColor(). None of them exi

3条回答
  •  孤街浪徒
    2021-01-14 06:30

    QGraphicsTextItem has a palette method which returns a QPalette and QPalette has the setColor method which takes a role.

    void QPalette::setColor ( ColorRole role, const QColor & color )
    
    The role you want is
    
    QPalette::Text  The foreground color used with Base. 
    This is usually the same as the WindowText, in which case it must provide 
    good contrast with Window and Base.
    

提交回复
热议问题