Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] QML color as QString
Forum Updated to NodeBB v4.3 + New Features

[Solved] QML color as QString

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 5.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ephe
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • I Offline
      I Offline
      ixSci
      wrote on last edited by
      #2

      you've tried and it didn't work?

      1 Reply Last reply
      0
      • E Offline
        E Offline
        ephe
        wrote on last edited by
        #3

        I'm really sorry, I don't know what I did wrong before, but it seems to be working now.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          ephe
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved