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. Want to get each color of QColorDialog in hexrgb format and store into a const char
Qt 6.11 is out! See what's new in the release blog

Want to get each color of QColorDialog in hexrgb format and store into a const char

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.5k Views 3 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    I have following code and I have to convert each QColor returned from getColor of QColorDialog into to hexrgb for example #ff0000 and store into a buf

    char buf[128]
    for(int i =0 ; i < 1000 ;i++) {
    QColor c = QColorDialg::getColor(i);
    buf should store the rgb format
    }

    Can someone guide for this

    Joel BodenmannJ 1 Reply Last reply
    0
    • Q Qt Enthusiast

      I have following code and I have to convert each QColor returned from getColor of QColorDialog into to hexrgb for example #ff0000 and store into a buf

      char buf[128]
      for(int i =0 ; i < 1000 ;i++) {
      QColor c = QColorDialg::getColor(i);
      buf should store the rgb format
      }

      Can someone guide for this

      Joel BodenmannJ Offline
      Joel BodenmannJ Offline
      Joel Bodenmann
      wrote on last edited by Joel Bodenmann
      #2

      QColor::name() returns the RGB string describing the color. I guess that's all you need :)

      Industrial process automation software: https://simulton.com
      Embedded Graphics & GUI library: https://ugfx.io

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        QColorDialog cannot give you colors like that.

        Also, there are millions of colors so what 1000 are you after?

        you can create colors using QColor col(R,G,B);
        where R;G;B are variables

        and you can get hex format with
        http://doc.qt.io/qt-5/qcolor.html#name

        1 Reply Last reply
        3

        • Login

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