我想从纯文本中获取文本颜色。我可以使用 charFormat() 获得 fontWeight 和其他格式,但是当我调试前景色时,它被设置为无颜色!!?
请帮我 ....
示例代码:
QTextCursor c = textCursor();
QTextCharFormat result = c.charFormat();
if (result.fontWeight() == QFont::Bold)
qDebug() << "bold text"; //worked
else if (result.fontWeight() == QFont::Normal)
qDebug() << "normal text"; //worked
if (result.foreground().color() == Qt::green)
qDebug() << "green"; //not worked !!
else if (result.foreground().color() == Qt::blue)
qDebug() << "blue"; //not worked !!
else
qDebug() << "no color !!";
TNX