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. How to convert rgb value to QColor?
Forum Update on Monday, May 27th 2025

How to convert rgb value to QColor?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 6 Posters 6.3k Views
  • 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.
  • K Offline
    K Offline
    kishore_hemmady
    wrote on last edited by kishore_hemmady
    #1

    hi,

    I have r g b value ,how can i covert that into QColor object ?

    raven-worxR JonBJ 2 Replies Last reply
    -2
    • K kishore_hemmady

      hi,

      I have r g b value ,how can i covert that into QColor object ?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @kishore_hemmady
      so like in your other topics you really refuse to take a look at the docs at all, right?!

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      6
      • K kishore_hemmady

        hi,

        I have r g b value ,how can i covert that into QColor object ?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @kishore_hemmady
        If you don't want to read through the docs, how about Googling for QColor rgb? It's actually quicker than posting a question....

        1 Reply Last reply
        4
        • J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by J.Hilk
          #4

          Here's an easy how to, in case you're using QtCreator as your IDE:

          • write QColor;
          • move Courser in center of QColor;
          • Press F1, this will open the Context Help
          • Scroll down to Public Functions

          In 90% of all cases you'll find an answer to your question.

          Other IDEs/Frameworks would murder for a documentation like Qt has, so use it, it's powerfull!


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          3
          • Prince_0912P Offline
            Prince_0912P Offline
            Prince_0912
            wrote on last edited by
            #5

            Hi @kishore_hemmady ,
            It is very simple,

            QColor getColor;

            QColor newColor = getColor.fromRgb(int r, int g, int b, int a = 255);

            jsulmJ 1 Reply Last reply
            1
            • Prince_0912P Prince_0912

              Hi @kishore_hemmady ,
              It is very simple,

              QColor getColor;

              QColor newColor = getColor.fromRgb(int r, int g, int b, int a = 255);

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Prince_0912 It's even easier

              QColor color(red, green, blue);
              

              http://doc.qt.io/qt-5/qcolor.html#QColor-2
              And fromRgb() is static - you do not need a QColor instance to use it:

              QColor color = QColor::fromRgb(...);
              

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              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