How to change color of last character in QML Text?
Solved
QML and Qt Quick
-
wrote on 10 Aug 2020, 07:10 last edited by
Hello,
Is it possible to have different colors for the same QML Text component? I want a specefic color for my text last character. -
Hello,
Is it possible to have different colors for the same QML Text component? I want a specefic color for my text last character.@Babs QML and Text components support rich text formatting so something like this can work:
Text { anchors.fill:parent text: "Normal text <font color=\"#FF0000\">this part is red</font>" }
-
@Babs QML and Text components support rich text formatting so something like this can work:
Text { anchors.fill:parent text: "Normal text <font color=\"#FF0000\">this part is red</font>" }
wrote on 10 Aug 2020, 07:25 last edited by@J-Hilk can it work when my text are QString variables?
-
@Babs sure, you can reformat your strings to include the tags or do something like this
Text { anchors.fill:parent text: "%1<font color=\"#FF0000\">%2</font>".arg(stringA).arg(stringB) }
-
@Babs sure, you can reformat your strings to include the tags or do something like this
Text { anchors.fill:parent text: "%1<font color=\"#FF0000\">%2</font>".arg(stringA).arg(stringB) }
wrote on 10 Aug 2020, 07:29 last edited by@J-Hilk thank you
1/5