I need a function to add some HTML attribute to a QTextObject?
-
Are there any function act like this in Qt version 6.4.1:
// a QTextObject inherited class QTextCursor cursor = textCursor(); QtextBlock* blk = cursor.block(); QTextBlockFormat fmt = blk->format(); // method I wonder fmt.setHtmlAttribute(QTextBlockFormat::HtmlAttr::Style, "font-weight: 700"); qDebug() << toHtml();Will output
... <p style="font-weight: 700">current block</p> ...Without modifying the HTML through
setHtml(...)orsetFontWeight(int).Is there any way to do that in Qt 6? Thanks!
-
Are there any function act like this in Qt version 6.4.1:
// a QTextObject inherited class QTextCursor cursor = textCursor(); QtextBlock* blk = cursor.block(); QTextBlockFormat fmt = blk->format(); // method I wonder fmt.setHtmlAttribute(QTextBlockFormat::HtmlAttr::Style, "font-weight: 700"); qDebug() << toHtml();Will output
... <p style="font-weight: 700">current block</p> ...Without modifying the HTML through
setHtml(...)orsetFontWeight(int).Is there any way to do that in Qt 6? Thanks!
@JackMyson
Qt's rich text handling does not accept arbitrary HTML, only a subset. So I don't think it caters for you just inserting some HTML attribute. I would expect to accomplish your request viasetHtml(...)orsetFontWeight(int)?