如何在QGraphicsScene上绘制彩色文本? [英] How to draw colored text on QGraphicsScene?

查看:62
本文介绍了如何在QGraphicsScene上绘制彩色文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找诸如 QGraphicsTextItem :: setPen()之类的选项,甚至是 QFont :: setColor() QFont :: setForegroundColor().它们都不存在.

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

如何在QGraphicsScene上绘制彩色文本?我不想使用 QGraphicsTextItem :: setHtml()并使用HTML来做到这一点(尽管不确定是否可行).

How can I draw colored text on QGraphicsScene? I don't want to use QGraphicsTextItem::setHtml() and use HTML to do that (not sure if that's possible, though).

我正在使用Qt 4.7.4.

I'm using Qt 4.7.4.

推荐答案

您是否正在寻找 setPlainText() setDefaultTextColor()的组合?

Are you looking for a combination of setPlainText() and setDefaultTextColor()?

http://doc.qt.io/archives/qt-4.7/qgraphicstextitem.html#setPlainText

http://doc.qt.io/archives/qt-4.7/qgraphicstextitem.html#setDefaultTextColor

如果没有,我不确定我是否理解您的问题...

If not, I'm not sure I understand your question...

这篇关于如何在QGraphicsScene上绘制彩色文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆