How to convert rgb value to QColor?
-
hi,
I have r g b value ,how can i covert that into QColor object ?
-
@kishore_hemmady
so like in your other topics you really refuse to take a look at the docs at all, right?! -
@kishore_hemmady
If you don't want to read through the docs, how about Googling forQColor rgb
? It's actually quicker than posting a question.... -
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!
- write
-
Hi @kishore_hemmady ,
It is very simple,QColor getColor;
QColor newColor = getColor.fromRgb(int r, int g, int b, int a = 255);
-
@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(...);