Qt 6.11 is out! See what's new in the release
blog
[Solved] QML color as QString
QML and Qt Quick
4
Posts
2
Posters
6.2k
Views
1
Watching
-
Is it possible to set the colour of a rectangle with a QString?
I pass the string from C++ and then I want to use it like this:
Rectangle {
id: prompt_rectangle
color: inputText
anchors.fill: parent
}The string has values like "#ff0000" How can I assign that to color?
If possible, I do not want to use QColor. -
I'm really sorry, I don't know what I did wrong before, but it seems to be working now.
-
I found out what my problem was. If the QString cannot be parsed as a color, "Unable to assign QString to QColor" is shown. But if the QString is correct, it works.