[Solved] QML color as QString



  • 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.



  • you've tried and it didn't work?



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.