I am using some QML controls like GroupBox
and CheckBox
which have text associated with them. The default color of the text is black. However, I have these items on a dark background and would prefer using white for the text color. These items don't have a color property so I'm not sure what to do.
CheckBox {
text: "Check Me"
}
To wrap the line, set the wrapMode property and give the text an explicit width for it to wrap to.
QML is the language; its JavaScript runtime is the custom V4 engine, since Qt 5.2; and Qt Quick is the 2D scene graph and the UI framework based on it. These are all part of the Qt Declarative module, while the technology is no longer called Qt Declarative.
The elide property can alternatively be used to fit a single line of plain text to a set width. Note that the Supported HTML Subset is limited. Also, if the text contains HTML img tags that load remote images, the text is reloaded. Text provides read-only text.
Have you tried setting it as an entire sub-element of the checkbox?
CheckBox {
Text {
text: "Check Me"
color: "red"
}
}
I had the same problem with GroupBox so I wanted to post an answer for future reference. The problem can easily be fixed using HTML formatting. For instance to change the color:
GroupBox{
title: "<font color=\"white\">my title</font>"
}
Size and other formatting parameters can be changed the same way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With