Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QColor name to rgb name
Forum Updated to NodeBB v4.3 + New Features

QColor name to rgb name

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 6.0k 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.
  • R Offline
    R Offline
    Ruzik
    wrote on last edited by
    #1

    Hellow, how can i get rgb name from QColor
    For example
    I have QColor = Qt::black
    how can i get "rgb(0,0,0)"
    I try it:
    @c.toRgb().name()@
    But it is get me #000000 instead of rgb(0,0,0);
    Advance many thanks for your help

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      if you need rgb(0,0,0), you can do:

      @
      QColor c = Qt::black;
      QString text = QString("rgb(%1,%2,%3)").arg(c.red()).arg(c.green()).arg(c.blue());
      @

      Code is not tested, just written here

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        soroush
        wrote on last edited by
        #3

        Try this:
        @
        QColor c;
        //
        QString name = QString("rgb(%1,%2,%3)").arg(c.red()).arg(c.green()).arg(c.blue());
        @
        *EDIT:*As Gerolf said... >:(

        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