How to add color on specific words on QML Text

会有一股神秘感。 提交于 2020-04-27 06:39:07

问题


Hello i would like to add different color on specific words of a string to be used in QML Text

Text {

    text: "Blue Red Yellow Green"

}

I know that you can add color to the whole text, but i would like to add specific color on specific words. is this possible? and how is it achieved?


回答1:


Text items can display both plain and rich text. For example you can have:

Text {
    text: "<font color=\"#0000FF\">Blue</font> <font color=\"#FF0000\">Red</font>"
}


来源:https://stackoverflow.com/questions/55003748/how-to-add-color-on-specific-words-on-qml-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!