我一直在寻找像QGraphicsTextItem::setPen()
或甚至QFont::setColor()
或QFont::setForegroundColor()
的选项。它们都不存在。如何在QGraphicsScene上绘制彩色文字?
如何在QGraphicsScene上绘制彩色文字?我不想使用QGraphicsTextItem::setHtml()
并使用HTML来做到这一点(不知道如果这是可能的,但)。
我使用的是Qt 4.7.4。
我一直在寻找像QGraphicsTextItem::setPen()
或甚至QFont::setColor()
或QFont::setForegroundColor()
的选项。它们都不存在。如何在QGraphicsScene上绘制彩色文字?
如何在QGraphicsScene上绘制彩色文字?我不想使用QGraphicsTextItem::setHtml()
并使用HTML来做到这一点(不知道如果这是可能的,但)。
我使用的是Qt 4.7.4。
您是否正在寻找组合setPlainText()
和setDefaultTextColor()
?
http://doc.qt.io/archives/qt-4.7/qgraphicstextitem.html#setPlainText
http://doc.qt.io/archives/qt-4.7/qgraphicstextitem.html#setDefaultTextColor
如果不是这样,我不知道我理解你的问题......
QGraphicsTextItem有一个palette
方法返回一个QPalette
和QPalette
有setColor方法,它需要一个角色。
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.
scene.addText(tr("Hello World"))->setDefaultTextColor(Qt::white);
我找不到'QGraphicsTextItem ::调色板()'。 – Donotalo